Generalise type of forever

Don Stewart dons at galois.com
Mon Jan 7 01:38:41 EST 2008


dons:
> It's been pointed out by a couple of people that the type of forever
> is overly constrained. We get a few more useful programs for free
> if we change the type:
> 
>     [generalise type of 'forever' from returning m () to m a
>     Don Stewart <dons at galois.com>**20080107062656] {
>     hunk ./Control/Monad.hs 42
>     -    , forever       -- :: (Monad m) => m a -> m ()
>     +    , forever       -- :: (Monad m) => m a -> m a
>     hunk ./Control/Monad.hs 190
>     -forever     :: (Monad m) => m a -> m ()
>     +forever     :: (Monad m) => m a -> m a
>     }

And in fact,

      forever     :: (Monad m) => m a -> m b

is better still. :)

-- Don


More information about the Libraries mailing list