[Haskell-cafe] Is there a generic way to detect "mzero"?

Antoine Latter aslatter at gmail.com
Tue Mar 27 00:03:50 CEST 2012

On Mon, Mar 26, 2012 at 4:25 PM, Ting Lei <tinlyx at hotmail.com> wrote:
> Hi Antoine and Tobias (and everyone else),
> Thanks a lot for your answers. They are really helpful
> Can you please show me how to use the (Eq m) constraint to do this?
> Also, my general question (probably novice-level) is that in monadic
> programming, you can convert not necessarily monadic codes into monadic
> ones.
> I know for many cases, it is impossible to do the reverse conversion, e.g.
> you can't make a function involving real IO operations into a pure code.
> In other cases, for example, I may need to using things like Nothing as the
> "null" value as in other programming languages, just to represent a special
> "missing" value outside the regular type.
> Is mzero a reasonable replacement for this or is there any reasonable
> (abstract) approximation in Haskell for doing this? (Like "null", I need the
> ability to detect it.)

I think using 'Maybe' (with Nothing) is perfect for this - this
function should come in handy:



More information about the Haskell-Cafe mailing list