summaryrefslogtreecommitdiff
path: root/demo/listFun.ur
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/listFun.ur
parenta23f12953a60c8f8d663266a9644a08a905b7b36 (diff)
Simple listShop working
Diffstat (limited to 'demo/listFun.ur')
-rw-r--r--demo/listFun.ur24
1 files changed, 23 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