
On Sun, Jan 06, 2008 at 10:33:27PM -0800, Don Stewart wrote:
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
**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 } In particular, fail breaks out nicely.
> forever Nothing Nothing
Deadline: 12th January.
-- Don
Your new type is not more general, for it no longer satisfies e.g. "Maybe Int -> Maybe ()". I counter-propose using the principal type, m a -> m b. Stefan