Skip to content

Levity-polymorphic GADT causes a panic (tyConAppTyCon)

On any version of GHC that supports UnliftedDatatypes (e.g. 9.2), the following program causes a panic:

{-# LANGUAGE StandaloneKindSignatures, MagicHash, ExplicitForAll, PolyKinds,
             DataKinds, UnliftedDatatypes, GADTs #-}

module RepPolyGADT where

import GHC.Exts

type LPGADT :: forall (l :: Levity) -> TYPE (BoxedRep l)
data LPGADT l where
  MkLifted   :: Int  -> LPGADT Lifted
  MkUnlifted :: Int# -> LPGADT Unlifted

getInt# :: LPGADT l -> Int#
getInt# (MkLifted (I# i#)) = i#
getInt# (MkUnlifted i#)    = i#
ghc.exe: panic! (the 'impossible' happened)
  (GHC version 9.2.0.20210331:
        tyConAppTyCon
  l_ayy
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler\\GHC\\Utils\\Panic.hs:181:37 in ghc:GHC.Utils.Panic
        pprPanic, called at compiler\\GHC\\Core\\Type.hs:1426:52 in ghc:GHC.Core.Type
Edited by sheaf
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information