Type Family fails to reduce without PolyKinds extension
Summary
Sometimes without PolyKinds extension, type family fails to reduce to expected type.
Steps to reproduce
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UnsaturatedTypeFamilies #-}
module Test where
type family Id (x :: *) :: * where
Id a = a
type family Apply (f :: * -> *) (x :: *) :: * where
Apply f x = f x
foo :: Apply Id String
foo = "foo"
Above code will produce compile error:
Test.hs:13:7: error:
• Couldn't match type: Apply Id String
with: [Char]
Expected: Apply Id String
Actual: String
• In the expression: "foo"
In an equation for ‘foo’ foo = "foo"
|
13 | foo = "foo"
| ^^^^^
After adding the PolyKinds extension, everything works fine.