[Haskell-beginners] Re: Maybe, Either

Heinrich Apfelmus apfelmus at quantentunnel.de
Tue Sep 15 06:25:43 EDT 2009


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



More information about the Beginners mailing list