How can I make a counter without Monad?

Tomasz Zielonka tomasz.zielonka at
Wed Mar 16 05:08:03 EST 2005

On Wed, Mar 16, 2005 at 01:17:51AM +0100, Nicolas Oury wrote:
> * linear implicit parameters
> instance Splittable Int where
>   split n = (2*n,2*n+1)
> But I have a problem : the counter value increases exponentially. (I 
> can only count up to 32 elements...)
> Is there another way to split Int?

You could use unbounded Integers, or forget about numbers and use lists
of bits.

  newtype BitString = BitString [Bool]

  instance Splittable BitString where
    split (BitString bs) = (BitString (False : bs), BitString (True : bs))

Best regards

More information about the Glasgow-haskell-users mailing list