Skip to content

Panic: No skolem info when DerivingVia levity-polymorphic class

I am using GHC 9.2.1 on NixOS.

Minimal repro:

❯ cat Main.hs
{-# language
    DerivingStrategies
  , DerivingVia
  , GeneralisedNewtypeDeriving
  , StandaloneDeriving
#-}

module Main (main) where

import GHC.Exts (TYPE)
import GHC.Generics (Rec1)
import Data.Kind (Type)

main :: IO ()
main = pure ()

class FunctorL (f :: Type -> TYPE r) where
  fmapL :: (a -> b) -> (f a -> f b)

newtype Base1 f a = Base1 { getBase1 :: f a }
  deriving newtype (Functor)

instance Functor f => FunctorL (Base1 f) where
  fmapL = fmap

deriving via (Base1 (Rec1 f)) instance FunctorL (Rec1 f)
❯ ghc Main.hs
[1 of 1] Compiling Main             ( Main.hs, Main.o )

Main.hs:26:50: error:ghc: panic! (the 'impossible' happened)
  (GHC version 9.2.0.20210821:
	No skolem info:
  [k_a1aN]
  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/Tc/Errors.hs:2888:17 in ghc:GHC.Tc.Errors

Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug

I think this has something to do with the poly-kindedness of Rec1.

cc @Icelandjack @RyanGlScott

Edited by chessai
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information