
15 Sep
2009
15 Sep
'09
10:25 a.m.
Conor McBride wrote:
malt :: Alternative f => Maybe x -> f x malt = maybe empty pure
mop :: MonadPlus m => Maybe x -> m x mop = maybe mzero return
The message clearly bears repeating. Inductive definition is a concrete form of abstraction. Don't be fooled by its appearance: Maybe is the most abstract choice here -- the classier options demand more structure than is needed and thus exclude use-cases.
Seconded! Maybe is the most general choice. The only issue left here would be that the combinators malt and mop are missing from the standard library. Once again, their purpose is not generality, but the convenience of overloading. Regards, apfelmus -- http://apfelmus.nfshost.com