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,
~wren

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to