[Haskell-beginners] Rigid type variables match error

Felipe Lessa felipe.lessa at gmail.com
Sun Jun 28 23:09:23 EDT 2009


On Sat, Jun 27, 2009 at 10:18:02AM +0930, Darryn wrote:
> class A a where
>     a1 :: a
>     a2 :: a -> a
>     a3 :: (B b) => b -> a

It is clear here that 'b' is different from 'a' on 'a3's
definition, right? Now let's rename 'b' to 'c' on your instance:

> -- note that 'a = Ainst c' here.
> instance (B c) => A (Ainst c) where
>     a1 :: Ainst c
>     a1 = I
>     a2 :: Ainst c -> Ainst c
>     a2 = J
>     a3 :: (B b) => b -> Ainst c
>     a3 = ...

Oops!  We have 'K :: (B b) => b -> Ainst b', but 'a3 :: (B b) =>
b -> Ainst c' is more general than that.

Hope that helps,

--
Felipe.


More information about the Beginners mailing list