Skip to content

TH crashes if you reify the Name of a dfun

Prelude Language.Haskell.TH Language.Haskell.TH.Syntax> $(fmap show (classInstances ''Eq [ConT ''Int] >>= reify . head) >>= lift)

<interactive>:1:3:
    Exception when trying to run compile-time code:
      <interactive>: panic! (the 'impossible' happened)
  (GHC version 7.0.1 for x86_64-unknown-linux):
	reifyType PredTy
    <pred>base:GHC.Classes.Eq{tc 23} ghc-prim:GHC.Types.Int{(w) tc 3J}

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

      Code: (>>=)
              fmap
                (show)
                ((>>=)
                   classInstances 'Eq [Language.Haskell.TH.Syntax.ConT 'Int]
                   (.) reify head)
              lift
    In the expression:
      $(fmap show (classInstances 'Eq [ConT 'Int] >>= reify . head)
      >>=
        lift)
    In an equation for `it':
        it
          = $(fmap show (classInstances 'Eq [ConT 'Int] >>= reify . head)
            >>=
              lift)

The same thing happens when compiling with ghc rather than using GHCi. Also, it looks like the pretty printer is displaying ''Eq and ''Int incorrectly.

Trac metadata
Trac field Value
Version 7.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information