Commit 4da8e73d authored by eir@cis.upenn.edu's avatar eir@cis.upenn.edu
Browse files

Fix #11754 by adding an additional check.

This was just plain wrong previously.

Test case: typecheck/should_compile/T11754
parent 882179de
......@@ -874,10 +874,11 @@ etaTyConAppCo_maybe tc (TyConAppCo _ tc2 cos2)
etaTyConAppCo_maybe tc co
| mightBeUnsaturatedTyCon tc
, Pair ty1 ty2 <- coercionKind co
, (Pair ty1 ty2, r) <- coercionKindRole co
, Just (tc1, tys1) <- splitTyConApp_maybe ty1
, Just (tc2, tys2) <- splitTyConApp_maybe ty2
, tc1 == tc2
, isInjectiveTyCon tc r -- See Note [NthCo and newtypes] in TyCoRep
, let n = length tys1
= ASSERT( tc == tc1 )
ASSERT( n == length tys2 )
......
{-# LANGUAGE TypeOperators, UndecidableSuperClasses, KindSignatures,
TypeFamilies, FlexibleContexts #-}
module T11754 where
import Data.Kind
import Data.Void
newtype K a x = K a
newtype I x = I x
data (f + g) x = L (f x) | R (g x)
data (f × g) x = f x :×: g x
class Differentiable (D f) => Differentiable f where
type D (f :: Type -> Type) :: Type -> Type
instance Differentiable (K a) where
type D (K a) = K Void
instance Differentiable I where
type D I = K ()
instance (Differentiable f, Differentiable f) => Differentiable (f + f) where
type D (f + f) = D f + D f
instance (Differentiable f, Differentiable f) => Differentiable (f × f) where
type D (f × f) = (D f × f) + (f × D f)
......@@ -510,3 +510,4 @@ test('T11608', normal, compile, [''])
test('T11401', normal, compile, [''])
test('T11699', normal, compile, [''])
test('T11512', normal, compile, [''])
test('T11754', normal, compile, [''])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment