GHC panic with -XDerivingVia
I slipped up and typed Codensity GEndo
instead of Codensity (GEndo m)
, resulting in a GHC panic
{-# Language RankNTypes #-}
{-# Language DerivingVia #-}
import Control.Monad.Codensity
import Data.Kind
newtype GEndo m a = GEndo (m a -> m a)
newtype LogicT m a = LogicT { runLogicT :: forall xx. (a -> (m xx -> m xx)) -> (m xx -> m xx) }
deriving
(Functor, Applicative, Monad)
via
(Codensity GEndo)
$ ghci -ignore-dot-ghci 476.hs
GHCi, version 8.7.20180828: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( 476.hs, interpreted )
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 8.7.20180828 for x86_64-unknown-linux):
ASSERT failed!
Type-correct unfilled coercion hole {co_a2aG}
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/utils/Outputable.hs:1219:5 in ghc:Outputable
assertPprPanic, called at compiler/typecheck/TcHsSyn.hs:1716:99 in ghc:TcHsSyn
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
>
Deriving via Codensity (GEndo m)
works as expected.