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 => []
| Cons (x, ls') => {[M.toString x]} :: {toXml ls'}
fun console (ls : list M.t) =
let
fun cons (r : {X : string}) =
case M.fromString r.X of
None => return Invalid string!
| Some v => console (Cons (v, ls))
in
return
Current list: {toXml ls}
Reversed list: {toXml (rev ls)}
Length: {[length ls]}
end
fun main () = console Nil
end