Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#10960 closed bug (duplicate)

Closed type families don't reduce on data family instances

Reported by: exFalso Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.10.2
Keywords: closed type family data Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: GHC rejects valid program Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


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


    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?

Change History (2)

comment:1 Changed 3 years ago by goldfire

Resolution: duplicate
Status: newclosed

It's a bug. Fixed in HEAD and the fix will be in 7.10.3. See #10713.

Thanks for reporting!

comment:2 Changed 3 years ago by exFalso

A note to anyone encountering this same problem: There is a weird workaround, at least for the above problem:

type family T a where
  T () = ()
  T (f a) = Char -- (D ()) reduces here
  T a = Char
Note: See TracTickets for help on using tickets.