[Haskell-cafe] Are all monads functions?

Ertugrul Söylemez es at ertes.de
Sun Jan 1 05:17:12 CET 2012

Yves Parès <limestrael+haskell at gmail.com> wrote:

> But still, I maintain my previous view. I could clarify that by saying
> that (e.g. for Maybe) we could separate it in two types, Maybe itself
> and its monad:
> -- The plain Maybe type
> data Maybe a = Just a | Nothing
> -- The MaybeMonad
> newtype MaybeMonad a = MM ( () -> Maybe a )
> That's what using Maybe as a monad semantically means, doesn't it?

That's a statement like "the sky is blue".  You can represent any value
as a function of ().  You are saying that every integer is a function.

    newtype MyInt = MyInt (() -> Int)
    newtype My a = My (() -> a)

Think of it this way:  There is something like a canonical
representation of every monad.  If you let that one be the one with the
least order (which is reasonable), then no, not every monad's canonical
representation is a function, because the base library definition of
Maybe is the canonical one (order zero).

In that sense every value in maths is a function.  In other words: Your
extension of everything (!) to functions is redundant.

You get the idea.


nightmare = unsafePerformIO (getWrongWife >>= sex)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120101/c6ae93f2/attachment.pgp>

More information about the Haskell-Cafe mailing list