Skip to content

panic with complicated type/kind/class expressions

I tried to simplify this as much as I could, but I couldn't boil it down further than this:

-- ghc -O -ddump-hi -ddump-to-file Bug.hs
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE GADTs #-}
module Bug where
{
    import Data.Kind;

    data HetEq (a :: ka) (b :: kb) where
    {
        ReflH :: forall (k :: *) (t :: k). HetEq t t;
    };

    data Rep :: forall (k :: *). k -> * where
    {
        SimpleRep :: forall (k :: *) (a :: k). Rep a;
        ApplyRep :: forall (k1 :: *) (k2 :: *) (p :: k1 -> k2) (a :: k1). Rep p -> Rep a -> Rep (p a);
    };

    class TestHetEquality (w :: forall k. k -> *) where
    {
        testHetEquality :: forall (ka :: *) (a :: ka) (kb :: *) (b :: kb). w a -> w b -> Maybe (HetEq a b);
    };

    instance TestHetEquality Rep where
    {
        testHetEquality (ApplyRep tfa ta) (ApplyRep tfb tb) = do
        {
            ReflH <- testHetEquality tfa tfb;
            ReflH <- testHetEquality ta tb;
            return ReflH;
        };
        testHetEquality _ _ = Nothing;
    };

    bug :: forall (a :: *). Rep (Maybe a) -> Maybe (Rep a);
    bug (ApplyRep tf ta) = case testHetEquality tf SimpleRep of
    {
        Just ReflH  -> Just ta;
        Nothing -> Nothing;
    };
    bug _ = Nothing;
}

You'll need -O and -ddump-hi to trigger it.

$ stack exec -- ghc -O -ddump-hi -ddump-to-file Bug.hs
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.0.1 for x86_64-unknown-linux):
	pprIfaceCo

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
Trac metadata
Trac field Value
Version 8.0.1
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