[Haskell-beginners] Are monads pure?

aditya siram aditya.siram at gmail.com
Mon May 17 23:43:48 EDT 2010

Threading state is something that the State monad does and it is
purely functional - showing that a monad *can* be pure but don't have
to be. Other monads, like IO as you have stated, have side effects.

At the end of the day I found that the monad is very, very general and
it's best way to think about it as a piece of data wrapped in some
type. With a monad you can
1. takes some data and wraps it up in a type (return) :
a -> m a
2. apply a function to the data within the type (>>=).
m a -> (a -> m b) -> m b


On 5/17/10, Amy de Buitléir <amy at nualeargais.ie> wrote:
> When I first started learning Haskell, I was under the impression that
> monads provided a way to encapsulate some imperative code so it didn't
> "contaminate" your functional code. But I think that's a misconception that
> I got because the first monad I dealt with was IO. Lately I've been reading
> more about monads, and (aside from IO), they are purely functional, aren't
> they? If they have state, they deal with it in a purely functional way.
> Behind the scenes, they thread the state through your computations so that
> you don't you don't have to bother with it. Is that correct? TIA.

More information about the Beginners mailing list