adamc@398: open List adamc@398: adamc@386: functor Make(M : sig adamc@386: type t adamc@398: val toString : t -> string adamc@398: val fromString : string -> option t adamc@386: end) = struct adamc@398: fun toXml (ls : list M.t) = adamc@398: case ls of adamc@398: Nil => [] adamc@398: | Cons (x, ls') => {[M.toString x]} :: {toXml ls'} adamc@398: adamc@501: fun console (ls : list M.t) = adamc@501: let adamc@501: fun cons (r : {X : string}) = adamc@501: case M.fromString r.X of adamc@501: None => return Invalid string! adamc@501: | Some v => console (Cons (v, ls)) adamc@501: in adamc@501: return adamc@501: Current list: {toXml ls}
adamc@501: Reversed list: {toXml (rev ls)}
adamc@501: Length: {[length ls]}
adamc@501:
adamc@398: adamc@501:
adamc@501: Add element: adamc@501: adamc@501:
adamc@501: end adamc@398: adamc@398: fun main () = console Nil adamc@386: end