Skip to content

Incorrect error message when compiling with PolyKinds and a type family

When trying to compile

{-# LANGUAGE TypeFamilies,
             PolyKinds,
             ScopedTypeVariables
 #-}

convert :: a -> b
convert = undefined

type family Foo a

bar :: forall b a. b -> (Foo a)
bar f = (convert f :: (Foo a))

I get the following error message:

Sandbox.hs:12:10:
    Couldn't match type `Foo k a' with `Foo * b'
    NB: `Foo' is a type function, and may not be injective
    In the expression: (convert f :: Foo a)
    In an equation for `bar': bar f = (convert f :: Foo a)

However, this compiles just fine without PolyKinds.

Trac metadata
Trac field Value
Version 7.4.1-rc1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information