Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#8548 closed bug (fixed)

Coercible does not resolve type family application

Reported by: nomeata Owned by: nomeata
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 7.6.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: typecheck/should_run/TcCoercible
Blocked By: Blocking: #8503
Related Tickets: #8503 Differential Rev(s):
Wiki Page:


With GND implemented using Coercible (See #8503) the test for #4185 fails. A minimal example is:

{-# LANGUAGE TypeFamilies #-}
module CoerceNewtypeFamily where
import GHC.Exts
data family Foo k
newtype instance Foo Int = FooInt Int 
x :: Foo Int -> Int
x = coerce


[1 of 1] Compiling CoerceNewtypeFamily ( CoerceNewtypeFamily.hs, CoerceNewtypeFamily.o )

    No instance for (Coercible (Foo Int) Int)
      because ‛Foo Int’ and ‛Int’ are different types.
      arising from a use of ‛coerce’
    In the expression: coerce
    In an equation for ‛x’: x = coerce

I guess the Coercible finding code needs to simply type family equations if possible.

Change History (8)

comment:1 Changed 4 years ago by nomeata

Blocking: 8503 added

comment:2 Changed 4 years ago by nomeata

(Also breaks the test case for #5955, #2856 and test case DerivingNewType)

comment:3 Changed 4 years ago by nomeata

(You can add #2850 to that list, it seems)

comment:4 Changed 4 years ago by nomeata

Fixed (not yet pushed), solves all listed tickets.

comment:5 Changed 4 years ago by Joachim Breitner <mail@…>

In 335031f0cbc03a8d3ba893b0dabb71088665e748/ghc:

Extend Coercible to newtype instances

This fixes: #8548

comment:6 Changed 4 years ago by Joachim Breitner <mail@…>

In 8949a7cc453a7aec9bbcb752a07c140c2f15a619/testsuite:

Testcase for Coercible and newtype families (#8548)

comment:7 Changed 4 years ago by nomeata

Resolution: fixed
Status: newclosed

This has hit master together with the changes for #8503, closing.

comment:8 Changed 3 years ago by goldfire

Test Case: typecheck/should_run/TcCoercible
Note: See TracTickets for help on using tickets.