summaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-10-21 13:24:54 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-10-21 13:24:54 -0400
commitac6a32c651d76d10650fffb99f77f05c583ff0cf (patch)
treee9764619179aa37aef1cdfa46612020e176c1a1d /demo
parenta23f12953a60c8f8d663266a9644a08a905b7b36 (diff)
Simple listShop working
Diffstat (limited to 'demo')
-rw-r--r--demo/listFun.ur24
-rw-r--r--demo/listFun.urs2
-rw-r--r--demo/listShop.ur4
-rw-r--r--demo/listShop.urp1
4 files changed, 30 insertions, 1 deletions
diff --git a/demo/listFun.ur b/demo/listFun.ur
index 833aee51..74f249b6 100644
--- a/demo/listFun.ur
+++ b/demo/listFun.ur
@@ -1,5 +1,27 @@
+open List
+
functor Make(M : sig
type t
+ val toString : t -> string
+ val fromString : string -> option t
end) = struct
- fun main () = return <xml/>
+ fun toXml (ls : list M.t) =
+ case ls of
+ Nil => <xml>[]</xml>
+ | Cons (x, ls') => <xml>{[M.toString x]} :: {toXml ls'}</xml>
+
+ fun console (ls : list M.t) = return <xml><body>
+ Current list: {toXml ls}<br/>
+
+ <form>
+ Add element: <textbox{#X}/> <submit action={cons ls}/>
+ </form>
+ </body></xml>
+
+ and cons (ls : list M.t) (r : {X : string}) =
+ case M.fromString r.X of
+ None => return <xml><body>Invalid string!</body></xml>
+ | Some v => console (Cons (v, ls))
+
+ fun main () = console Nil
end
diff --git a/demo/listFun.urs b/demo/listFun.urs
index 8fd6eb0d..909bbcf6 100644
--- a/demo/listFun.urs
+++ b/demo/listFun.urs
@@ -1,5 +1,7 @@
functor Make(M : sig
type t
+ val toString : t -> string
+ val fromString : string -> option t
end) : sig
val main : unit -> transaction page
end
diff --git a/demo/listShop.ur b/demo/listShop.ur
index 04386349..0c23819f 100644
--- a/demo/listShop.ur
+++ b/demo/listShop.ur
@@ -1,9 +1,13 @@
structure I = struct
type t = int
+ val toString = show _
+ val fromString = read _
end
structure S = struct
type t = string
+ val toString = show _
+ val fromString = read _
end
structure IL = ListFun.Make(I)
diff --git a/demo/listShop.urp b/demo/listShop.urp
index 85d318d4..219c6828 100644
--- a/demo/listShop.urp
+++ b/demo/listShop.urp
@@ -1,3 +1,4 @@
+debug
list
listFun