diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-04-30 11:07:29 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-04-30 11:07:29 -0400 |
commit | 43b09eea446f8d02ee82360d229b1ce2ba65f6f8 (patch) | |
tree | be8dc60f901b2cab9ec630d505bf152d1d19340e /tests | |
parent | 0f298a5396cf95f4e58988583f862a4b97444bec (diff) |
Basis.list
Diffstat (limited to 'tests')
-rw-r--r-- | tests/list.ur | 30 | ||||
-rw-r--r-- | tests/list.urp | 3 | ||||
-rw-r--r-- | tests/list.urs | 1 |
3 files changed, 18 insertions, 16 deletions
diff --git a/tests/list.ur b/tests/list.ur index a4602d0e..815c0075 100644 --- a/tests/list.ur +++ b/tests/list.ur @@ -1,19 +1,17 @@ -datatype list a = Nil | Cons of a * list a +fun isNil (t ::: Type) (ls : list t) = + case ls of + Nil => True + | _ => False -val isNil = fn t ::: Type => fn ls : list t => - case ls of Nil => True | _ => False +fun delist (ls : list string) : xbody = + case ls of + Nil => <xml>Nil</xml> + | Cons (h, t) => <xml>{[h]} :: {delist t}</xml> -val show = fn b => if b then "True" else "False" +fun main () = return <xml><body> + {[isNil (Nil : list bool)]}, + {[isNil (Cons (1, Nil))]}, + {[isNil (Cons ("A", Cons ("B", Nil)))]} -val rec delist : list string -> xml body [] [] = fn x => - case x of - Nil => <body>Nil</body> - | Cons (h, t) => <body>{cdata h} :: {delist t}</body> - -val main : unit -> page = fn () => <html><body> - {cdata (show (isNil (Nil : list bool)))}, - {cdata (show (isNil (Cons (1, Nil))))}, - {cdata (show (isNil (Cons ("A", Cons ("B", Nil)))))} - - <p>{delist (Cons ("X", Cons ("Y", Cons ("Z", Nil))))}</p> -</body></html> + <p>{delist (Cons ("X", Cons ("Y", Cons ("Z", Nil))))}</p> +</body></xml> diff --git a/tests/list.urp b/tests/list.urp new file mode 100644 index 00000000..d222b71a --- /dev/null +++ b/tests/list.urp @@ -0,0 +1,3 @@ +debug + +list diff --git a/tests/list.urs b/tests/list.urs new file mode 100644 index 00000000..6ac44e0b --- /dev/null +++ b/tests/list.urs @@ -0,0 +1 @@ +val main : unit -> transaction page |