[GHC] #15712: GHC panic with -XDerivingVia

#15712: GHC panic with -XDerivingVia -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Keywords: DerivingVia | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I slipped up and typed `Codensity GEndo` and now `Codensity (GEndo m)`, resulting in a GHC panic {{{#!hs {-# 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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15712 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15712: GHC panic with -XDerivingVia -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: | Keywords: DerivingVia Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by Iceland_jack: Old description:
I slipped up and typed `Codensity GEndo` and now `Codensity (GEndo m)`, resulting in a GHC panic
{{{#!hs {-# 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.
New description: I slipped up and typed `Codensity GEndo` instead of `Codensity (GEndo m)`, resulting in a GHC panic {{{#!hs {-# 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. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15712#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15712: GHC panic with -XDerivingVia -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: | Keywords: DerivingVia Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): This is without the https://hackage.haskell.org/package/kan- extensions-5.2/docs/Control-Monad-Codensity.html dependency {{{#!hs {-# Language RankNTypes #-} {-# Language DerivingVia #-} {-# Language DeriveFunctor #-} -- import Control.Monad.Codensity import Data.Kind newtype Codensity f a = Codensity (forall xx. (a -> f xx) -> f xx) deriving Functor newtype GEndo m a = GEndo (m a -> m a) newtype LogicT m a = LogicT (forall xx. (a -> (m xx -> m xx)) -> (m xx -> m xx)) deriving (Functor) via (Codensity GEndo) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15712#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15712: GHC panic with -XDerivingVia -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: | Keywords: DerivingVia Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): With HEAD, and GHC 8.6, for the code in comment:2 I get {{{ T15712.hs:20:16: error: • Expecting one more argument to ‘GEndo’ Expected kind ‘* -> *’, but ‘GEndo’ has kind ‘(* -> *) -> * -> *’ • In the first argument of ‘Codensity’, namely ‘GEndo’ In the newtype declaration for ‘LogicT’ | 20 | (Codensity GEndo) | ^^^^^ }}} Can others confirm? If so, could someone add a regression test and close? Thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15712#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC