Panic with -XDeriveFunctor when deriving from a non-Functor in a separate module
Mu in the same file
src/Main.hs
{-# LANGUAGE DeriveFunctor #-}
module Main where
newtype Mu f = Mu (f (Mu f))
newtype K a b = K a
newtype F a = F (Mu (K a)) deriving Functor
main :: IO ()
main = return ()
$ cabal build
Building panic-0.1.0.0...
Preprocessing executable 'panic' for panic-0.1.0.0...
[1 of 1] Compiling Main ( src/Main.hs, dist/build/panic/panic-tmp/Main.o )
src/Main.hs:7:37:
No instance for (Functor Mu)
arising from the first field of ‘F’ (type ‘Mu (K a)’)
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
When deriving the instance for (Functor F)
Mu in a separate file
src/Mu.hs
module Mu where
newtype Mu f = Mu (f (Mu f))
src/Main.hs
{-# LANGUAGE DeriveFunctor #-}
module Main where
import Mu
newtype K a b = K a
newtype F a = F (Mu (K a)) deriving Functor
main :: IO ()
main = return ()
$ cabal build
Building panic-0.1.0.0...
Preprocessing executable 'panic' for panic-0.1.0.0...
[1 of 2] Compiling Mu ( src/Mu.hs, dist/build/panic/panic-tmp/Mu.o )
[2 of 2] Compiling Main ( src/Main.hs, dist/build/panic/panic-tmp/Main.o )
src/Main.hs:8:37:ghc: panic! (the 'impossible' happened)
(GHC version 7.8.2 for x86_64-unknown-linux):
Prelude.(!!): index too large
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
Trac metadata
Trac field | Value |
---|---|
Version | 7.8.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |