diff options
Diffstat (limited to 'demo')
-rw-r--r-- | demo/listFun.ur | 24 | ||||
-rw-r--r-- | demo/listFun.urs | 2 | ||||
-rw-r--r-- | demo/listShop.ur | 4 | ||||
-rw-r--r-- | demo/listShop.urp | 1 |
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 |