[Haskell] Long live Edison
john at repetae.net
Mon Feb 20 22:33:24 EST 2006
On Mon, Feb 20, 2006 at 05:10:02PM -0800, Iavor Diatchki wrote:
> On 2/20/06, John Meacham <john at repetae.net> wrote:
> > I think the problem is that 'mzero' exists, the correct solution seems
> > to be to get rid of the 'mzero' method of MonadPlus. Since haskell is
> > lazy, all Monads have at least the zero of _|_ which can be overriden by
> > 'fail' with a more suitable one. MonadPlus should be about extending
> > monads with an additive operator, there is no need for another concept
> > of zero and it seems to me that is the real issue. mzero can simply be
> > defined as 'fail "mzero"'.
> In what sense is _|_ a 'zero'?
Ah, Sorry, I meant to say that every monad in haskell has a natural
'failure' and by the zero-as-failure model has a natural mzero too.
However that does weaken my argument if there are examples of monads
where having failure and zero be distinct is a useful thing. Consider my
argument weakened appropriatly. In any case, treating a map lookup as a
'failure' rather than a 'zero' does make more sense to me independent of
this and the need for error messages.
Actually, sort of on this note, I would like to see 'mempty' separated
out of the Monoid class... If we had class aliases ideally it would be
class MEmpty a where
mempty :: a
class MAppend a where
mappend :: a -> a -> a
class alias Monoid a = (MEmpty a,MAppend a) where
mconcat = foldr mappend mempty
not that I am seriously suggesting class aliases for haskell'. First a
few well tested implementations need to appear which I doubt will happen
before haskell' is well on its way.
John Meacham - ⑆repetae.net⑆john⑈
More information about the Haskell