Ticket #68 (closed defect: fixed)

Opened 9 years ago

Last modified 5 years ago

Internal error when splicing Template Haskell code

Reported by: spl Owned by:
Priority: major Milestone:
Version: 2.4.1 Keywords: TH
Cc: leather@…


The following two modules form a minimal testcase that produce an internal error from Haddock.


{-# LANGUAGE TemplateHaskell #-}
module A where
import Language.Haskell.TH
a = litE (charL 'a')


{-# LANGUAGE TemplateHaskell #-}
module B where
import A
b = $a

At the command line:

$ haddock B.hs 
haddock: internal Haddock or GHC error: Maybe.fromJust: Nothing

$ haddock --version
Haddock version 2.4.1, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008

$ haddock --ghc-version


  • The error also shows up in 2.3.0.
  • The error does not show up if you change B.hs to b = $(litE (charL 'a')).

Change History

Changed 9 years ago by waern

I think this is actually a problem in the GHC API:


Hopefully the fix will be in GHC 6.10.2, which will also come with the next version of Haddock.

Changed 9 years ago by waern

  • status changed from new to closed
  • resolution set to fixed
  • milestone changed from 2.5.0 to 2.4.2

This has been fixed by this patch:

* Fix Trac #68: Turn on compilation via C for Template Haskell packages
We can't use HscNothing if we need to run code coming from modules inside
the processed package during typechecking, which is the case for some packages
using Template Haskell. This could be improved, to e.g. use HscInterpreted and
HscNothing where possible, instead of using HscC for all modules in the

We should try to come up with a better solution in the future, where not all modules are compiled via C just because Template Haskell is used.

Changed 9 years ago by waern

I forgot to mention that you need to build Haddock with a recent version GHC HEAD for the fix to work!

Changed 9 years ago by SamB

  • keywords TH added

Changed 5 years ago by anonymous

  • milestone 2.4.2 deleted

Milestone 2.4.2 deleted

Note: See TracTickets for help on using tickets.