3 ms·
Close, but no cigar. functor MonadUtils (M : MONAD) = struct (* type annotations not strictly necessary *) fun sequence (ms : 'a M.monad list) : 'a l
by rntz 15y ago
Close, but no cigar.
functor MonadUtils (M : MONAD) = struct
(* type annotations not strictly necessary *)
fun sequence (ms : 'a M.monad list) : 'a list M.monad =
let fun mcons (elt, rest) = M.bnd elt (fn e => M.bnd rest (fn r => M.ret (e::r)))
in foldr mcons (M.ret []) ms
end
end