Skip to content

ghc panic when using DerivingVia

The following program results in a ghc panic:

{-# LANGUAGE DerivingVia #-}

import Data.Functor.Const (Const(..))
import Data.Functor.Classes

newtype FlipConst a b = FlipConst b
  deriving (Show1, Eq1) via (Const b)

Here is the output of the compile:

test/Spec/Contravariant.hs:52:13: error:
    • No instance for (Show b)
        arising from the 'deriving' clause of a data type declaration
      Possible fix:
        add (Show b) to the context of
          the deriving clause for ‘Show1 (FlipConst a)
        or use a standalone 'deriving instance' declaration,
             so you can specify the instance context yourself
    • When deriving the instance for (Show1 (FlipConst a))
   |
52 |   deriving (Show1, Eq1) via (Const b)
   |             ^^^^^

test/Spec/Contravariant.hs:52:13: error:ghc: panic! (the 'impossible' happened)
  (GHC version 8.6.3 for x86_64-unknown-linux):
	No skolem info:
  [b_a3eO]
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
        pprPanic, called at compiler/typecheck/TcErrors.hs:2891:5 in ghc:TcErrors

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

I'm using GHC 8.6.3

Trac metadata
Trac field Value
Version 8.6.3
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