blob: c4451e1db664e5cd30fdfd64694a6550cfa4872d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
open List
functor Make(M : sig
type t
val toString : t -> string
val fromString : string -> option t
end) = struct
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/>
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))
fun main () = console Nil
end
|