Skip to content

Closed type families don't reduce on data family instances

The following code doesn't compile:

{-# LANGUAGE TypeFamilies #-}
module Tmp where

data family D a
data instance D () = D

type family T a where
  T () = ()
  T a = Char

try :: T (D ()) ~ Char => ()
try = ()

main :: IO ()
main = return try

giving

Tmp.hs:15:15:
    Couldn't match expected type ‘Char’ with actual type ‘T (D ())’
    In the first argument of ‘return’, namely ‘try’
    In the expression: return try
    In an equation for ‘main’: main = return try

Is this a known limitation of closed type families?

Trac metadata
Trac field Value
Version 7.10.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
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