GHCi cannot reify a custom data constructor with Template Haskell on the first attempt
I've uncovered an unusual bug with Template Haskell inside of GHCi. To duplicate it, load GHCi, create a data type, then attempt to reify one of its constructors. It will fail the first time, but succeed the second time.
$ ghci -XTemplateHaskell
GHCi, version 7.8.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
λ> import Language.Haskell.TH
λ> data Option a = Some a | None
λ> $(reify 'Some >>= stringE . show)
Failed to load interface for ‘Ghci1’
no package matching ‘interactive’ was found
λ> $(reify 'Some >>= stringE . show)
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package containers-0.5.5.1 ... linking ... done.
Loading package pretty-1.1.1.1 ... linking ... done.
Loading package template-haskell ... linking ... done.
"DataConI Ghci1.Some (ForallT [PlainTV a_1627392303] [] (AppT (AppT ArrowT (VarT a_1627392303)) (AppT (ConT Ghci1.Option) (VarT a_1627392303)))) Ghci1.Option (Fixity 9 InfixL)"
Curiously, this doesn't happen when you reify a data constructor in base
, such as Just
:
$ ghci -XTemplateHaskell
GHCi, version 7.8.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
λ> import Language.Haskell.TH
λ> $(reify 'Just >>= stringE . show)
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package containers-0.5.5.1 ... linking ... done.
Loading package pretty-1.1.1.1 ... linking ... done.
Loading package template-haskell ... linking ... done.
"DataConI Data.Maybe.Just (ForallT [PlainTV a_1627398816] [] (AppT (AppT ArrowT (VarT a_1627398816)) (AppT (ConT Data.Maybe.Maybe) (VarT a_1627398816)))) Data.Maybe.Maybe (Fixity 9 InfixL)"
Trac metadata
Trac field | Value |
---|---|
Version | 7.8.4 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Template Haskell |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |