From 43b09eea446f8d02ee82360d229b1ce2ba65f6f8 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Thu, 30 Apr 2009 11:07:29 -0400 Subject: Basis.list --- tests/list.ur | 30 ++++++++++++++---------------- tests/list.urp | 3 +++ tests/list.urs | 1 + 3 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 tests/list.urp create mode 100644 tests/list.urs (limited to 'tests') 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 => Nil + | Cons (h, t) => {[h]} :: {delist t} -val show = fn b => if b then "True" else "False" +fun main () = return + {[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 => Nil - | Cons (h, t) => {cdata h} :: {delist t} - -val main : unit -> page = fn () => - {cdata (show (isNil (Nil : list bool)))}, - {cdata (show (isNil (Cons (1, Nil))))}, - {cdata (show (isNil (Cons ("A", Cons ("B", Nil)))))} - -

{delist (Cons ("X", Cons ("Y", Cons ("Z", Nil))))}

- +

{delist (Cons ("X", Cons ("Y", Cons ("Z", Nil))))}

+
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 -- cgit v1.2.3