[Haskell-cafe] Monads

wren ng thornton wren at freegeek.org
Sun Sep 30 20:40:31 CEST 2012

On 9/30/12 7:00 AM, Tillmann Rendel wrote:
> Vasili I. Galchin wrote:
>> I would an examples of monads that are pure, i.e. no side-effects.
> One view of programming in monadic style is: You call return and >>= all
> the time. (Either you call it directly, or do notation calls it for
> you). So if you want to understand whether a monad "has side-effects",
> you should look at the implementation of return and >>=. If the
> implementation of return and >>= is written in pure Haskell (without
> unsafePerformIO or calling C code etc.), the monad is pure.

I'm not sure return and bind will give you the information you seek, 
however. In order to obey the monad laws, return and bind must be (for 
all intents and purposes) pure.

The place to look for "impurities" is the primitive operations of the 
monad; i.e., those which cannot be implemented using return and bind. 
These are the operations which take you out of a free monad and the 
operations which must be given some special semantic interpretation.

Live well,

More information about the Haskell-Cafe mailing list