[Haskell-cafe] Rank N type tutorial?

David House dmhouse at gmail.com
Fri Oct 27 19:47:41 EDT 2006

On 28/10/06, Jason Dagit <dagit at codersbase.com> wrote:
> So you specified that the types which T' wraps up should be instances
> of Show, so to me it makes sense that you should be able to derive
> Show in a way similar to how newtype deriving works.  But perhaps
> there is a subtlety that I'm missing?

Not in this case, but this happens to be a specific case. For example,
imagine what would happen if we had chosen Eq instead of Show for the
class constraint. The compiler does as follows:

instance Eq T' where
  MkT' x == MkT y' = ...

Recall the type signiture for (==):

(==) :: Eq a => a -> a -> Bool

I.e. the types of its two arguments are required to unify. Even though
we know x :: exists a. Eq a => a and y :: exists b. Eq b => b, we
don't necessarily know that a is the same type as b, which means 'x ==
y' doesn't typecheck. Therefore, there's no obvious instance of Eq for

-David House, dmhouse at gmail.com

More information about the Haskell-Cafe mailing list