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