summaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-10-21 12:06:35 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-10-21 12:06:35 -0400
commita23f12953a60c8f8d663266a9644a08a905b7b36 (patch)
tree017e4ed05769d4fff43b3ecfef4cef440d68653a /demo
parentcd8ba90217f6ed7efbf4882b4dcd8e199e510fbb (diff)
ListShop skeleton
Diffstat (limited to 'demo')
-rw-r--r--demo/list.ur15
-rw-r--r--demo/list.urs5
-rw-r--r--demo/listFun.ur2
-rw-r--r--demo/listFun.urs1
-rw-r--r--demo/listShop.ur16
-rw-r--r--demo/listShop.urp4
-rw-r--r--demo/listShop.urs1
7 files changed, 42 insertions, 2 deletions
diff --git a/demo/list.ur b/demo/list.ur
new file mode 100644
index 00000000..c2dfce22
--- /dev/null
+++ b/demo/list.ur
@@ -0,0 +1,15 @@
+datatype list t = Nil | Cons of t * list t
+
+fun length' (t ::: Type) (ls : list t) (acc : int) =
+ case ls of
+ Nil => acc
+ | Cons (_, ls') => length' ls' (acc + 1)
+
+fun length (t ::: Type) (ls : list t) = length' ls 0
+
+fun rev' (t ::: Type) (ls : list t) (acc : list t) =
+ case ls of
+ Nil => acc
+ | Cons (x, ls') => rev' ls' (Cons (x, acc))
+
+fun rev (t ::: Type) (ls : list t) = rev' ls Nil
diff --git a/demo/list.urs b/demo/list.urs
new file mode 100644
index 00000000..e09f5118
--- /dev/null
+++ b/demo/list.urs
@@ -0,0 +1,5 @@
+datatype list t = Nil | Cons of t * list t
+
+val length : t ::: Type -> list t -> int
+
+val rev : t ::: Type -> list t -> list t
diff --git a/demo/listFun.ur b/demo/listFun.ur
index 7a3459aa..833aee51 100644
--- a/demo/listFun.ur
+++ b/demo/listFun.ur
@@ -1,5 +1,5 @@
functor Make(M : sig
type t
end) = struct
- val x = 6
+ fun main () = return <xml/>
end
diff --git a/demo/listFun.urs b/demo/listFun.urs
index ce4acafc..8fd6eb0d 100644
--- a/demo/listFun.urs
+++ b/demo/listFun.urs
@@ -3,4 +3,3 @@ functor Make(M : sig
end) : sig
val main : unit -> transaction page
end
-
diff --git a/demo/listShop.ur b/demo/listShop.ur
new file mode 100644
index 00000000..04386349
--- /dev/null
+++ b/demo/listShop.ur
@@ -0,0 +1,16 @@
+structure I = struct
+ type t = int
+end
+
+structure S = struct
+ type t = string
+end
+
+structure IL = ListFun.Make(I)
+structure SL = ListFun.Make(S)
+
+fun main () = return <xml><body>
+ Pick your poison:<br/>
+ <li> <a link={IL.main ()}>Integers</a></li>
+ <li> <a link={SL.main ()}>Strings</a></li>
+</body></xml>
diff --git a/demo/listShop.urp b/demo/listShop.urp
new file mode 100644
index 00000000..85d318d4
--- /dev/null
+++ b/demo/listShop.urp
@@ -0,0 +1,4 @@
+
+list
+listFun
+listShop
diff --git a/demo/listShop.urs b/demo/listShop.urs
new file mode 100644
index 00000000..6ac44e0b
--- /dev/null
+++ b/demo/listShop.urs
@@ -0,0 +1 @@
+val main : unit -> transaction page