[Haskell-cafe] Are all monads functions?

Conal Elliott conal at conal.net
Sun Jan 1 08:52:35 CET 2012


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

And function is not unique in this way. All types can be embedded into
pairs also, e.g., newtype MyInt = MyInt ((),Int), or newtype MyInt = MyInt
(((),Int),()), etc.

  - Conal

2011/12/31 Ertugrul Söylemez <es at ertes.de>

>  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.
>
>
> Greets,
> Ertugrul
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111231/912c6dbf/attachment.htm>


More information about the Haskell-Cafe mailing list