'Untouchable' error when using type function in class constraint in rank-2 type
I noticed there are some cases that no longer compile after the recent fix for #8644 (closed), such as the following:
{-# LANGUAGE RankNTypes, FlexibleContexts, TypeFamilies #-}
import Data.Monoid
type family Id a
type instance Id a = a
--type instance Id [a] = [Id a]
foo :: (Monoid (Id String) => r) -> r
foo x = x
main :: IO ()
main = print $ foo "Hello"
Attempting to compile this on HEAD produces the same error in 'main' as reported in the earlier ticket:
Couldn't match expected type ‛s0’ with actual type ‛[Char]’
‛s0’ is untouchable
However, it compiles fine if the commented-out type family instance is used instead. It also compiles fine if the type family is replaced with an ordinary type synonym:
type Id a = a
I guess that the problem is caused by equalities of the form t ~ [Char] introduced by the type family instance.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.7 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |