How can I make a counter without Monad?

Tomasz Zielonka tomasz.zielonka at
Wed Mar 16 05:02:23 EST 2005

On Wed, Mar 16, 2005 at 10:51:08AM +0100, Nicolas Oury wrote:
> Thanks for your help.
> >>Are there other ways to implement a counter in Haskell?
> >
> >Using a State monad?
> >
> If I use your example on :
> test   = let Node x l = enumeratedTree ( Node 'a' [undefined, Node 'b' 
> []])
> 			in tail l
> GHCI answers
> [Node (*** Exception: Prelude.undefined
> 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.

OK, I understand. In this situation you probably want either splittable
name supply. Let me get back to your first post...

Best regards

More information about the Glasgow-haskell-users mailing list