External preprocessor not used after TH name quote
Module
{-# LANGUAGE CPP, TemplateHaskell #-}
module Main where
main = do
putStrLn $ show 'id
putStrLn __FILE__
fails to compile with external preprocessor:
> ghc -pgmP cpphs -optP --cpp Main.hs
[1 of 1] Compiling Main ( Main.hs, Main.o )
Main.hs:7:12: Not in scope: `__FILE__'
__FILE__
is not expanded:
> ghc -E -pgmP cpphs -optP --cpp Main.hs
> cat Main.hspp
{-# LINE 1 "Main.hs" #-}
#line 1 "Main.hs"
{-# LANGUAGE CPP, TemplateHaskell #-}
module Main where
main = do
putStrLn $ show 'id
putStrLn __FILE__
Without external preprocessor (just ghc Main.hs
) module compiles successfully.
Move name quote after __FILE__
, like this:
{-# LANGUAGE CPP, TemplateHaskell #-}
module Main where
main = do
putStrLn __FILE__
putStrLn $ show 'id
and it work with external preprocessor just fine:
> ghc -pgmP cpphs -optP --cpp Main.hs
[1 of 1] Compiling Main ( Main.hs, Main.o )
Linking Main ...
> ./Main
Main.hs
GHC.Base.id
Trac metadata
Trac field | Value |
---|---|
Version | 7.4.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |