Restricted Data Types: A reformulation

Ashley Yakeley ashley at semantic.org
Tue Feb 7 20:54:51 EST 2006


John Meacham wrote:

> newtype Eq a => Set a = Set (List a)
> singleton :: Eq a => a -> Set a
> class Monad m where
>         return :: a -> m a
> 
> instance Monad Set where
>         return x = singleton x
> 
> okay, our goal is to make this typesafe. 

You shouldn't be able to, should you? Monad makes a promise that Set 
can't keep. In particular:

  returnid :: (Monad m) => m (a -> a)
  returnid = return id

  bad :: Set (a -> a)
  bad = returnid



More information about the Haskell-prime mailing list