How can I make a counter without Monad?

John Meacham john at
Wed Mar 16 18:25:19 EST 2005

On Wed, Mar 16, 2005 at 10:51:08AM +0100, Nicolas Oury wrote:
> A monadic counter imposes an order of evaluation.
> In my program, I don't care about the order of the numbers.
> I only want them to be all different.
> I think a monad is too restrictive for what I need.

This is a common misconception, there is nothing about monads that
requires an order of evaluation. for instance none of 

Control.Monad.Identity - isomorphic to not using monads at all
Control.Monad.Reader - distributes a value to subcomputations
Control.Monad.Writer - collects values from subcomputations

imply any particular order of evaluation. This is one of the major
powers of Monads,  they can encapsulate all sorts of 'side effects', not
just order of evaluation or linear state. 

for this app, I would use Control.Monad.State or if I needed the extra
lazyness, Control.Monad.Reader with an explicitly splittable namesupply.

John Meacham - ⑆⑆john⑈ 

More information about the Glasgow-haskell-users mailing list