Skip to content

Levity polymorphism panic

I imagine I have made a mistake, but GHC shouldn't panic!

{-# language TypeInType, ScopedTypeVariables, MagicHash #-}

import GHC.Exts (TYPE, Proxy#, proxy#)

fold :: forall rep a (r :: TYPE rep).
          (r -> a -> Proxy# r -> r) -> (Proxy# r -> r) -> [a] -> r
fold f k [] = k proxy#
fold f k (x : xs) = fold f (f (k proxy#) x) xs

This gives me

ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 8.5.20171211 for x86_64-unknown-linux):
        splitFunTy
  ()
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
        pprPanic, called at compiler/types/Type.hs:921:30 in ghc:Type
Trac metadata
Trac field Value
Version 8.5
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