Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,826
    • Issues 4,826
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 440
    • Merge requests 440
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #9071

Closed
Open
Created May 03, 2014 by bens@trac-bens

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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking