Restricted Data Types: A reformulation
Ashley Yakeley
ashley at semantic.org
Tue Feb 7 22:59:46 EST 2006
John Meacham wrote:
> however, (Set (a -> a)) is malformed. since a _requirement_ is that Set
> can only be applied to a type with an Eq constraint so the instance you
> try to do something like
>
> returnid :: Set (a -> a) -- ^ static error! you need
>
> returnid :: Eq (a -> a) => Set (a -> a)
>
> the instant you introduce 'Set' you introduce the 'Eq' constraint. as
> long as you are just working on generic monads then there is no need for
> the Eq constraint.
OK, try this:
foo :: (Monad m) => m Int
foo = return id >>= (\i -> i 7)
fooSet :: Set Int
fooSet = foo
Since we have (Eq Int), your type-checker should allow this. But your
instance implementation of return and (>>=) made assumptions about their
arguments that foo does not stick to.
--
Ashley Yakeley
More information about the Haskell-prime
mailing list