Mercurial > urweb
diff demo/listFun.ur @ 501:7ef4b2911b09
Some demo improvements
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 20 Nov 2008 11:34:36 -0500 |
parents | e756d3a47726 |
children |
line wrap: on
line diff
--- a/demo/listFun.ur Thu Nov 20 10:44:28 2008 -0500 +++ b/demo/listFun.ur Thu Nov 20 11:34:36 2008 -0500 @@ -10,21 +10,24 @@ 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/> - Reversed list: {toXml (rev ls)}<br/> - Length: {[length ls]}<br/> - <br/> + fun console (ls : list M.t) = + let + fun cons (r : {X : string}) = + case M.fromString r.X of + None => return <xml><body>Invalid string!</body></xml> + | Some v => console (Cons (v, ls)) + in + return <xml><body> + Current list: {toXml ls}<br/> + Reversed list: {toXml (rev ls)}<br/> + Length: {[length ls]}<br/> + <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)) + <form> + Add element: <textbox{#X}/> <submit action={cons}/> + </form> + </body></xml> + end fun main () = console Nil end