Last active
August 29, 2015 14:12
-
-
Save carymrobbins/8345cdcf7830fd6b1a6e to your computer and use it in GitHub Desktop.
Example of CPP and QuasiQuotes causing GHC to report the wrong line numbers for type errors (see https://ghc.haskell.org/trac/ghc/ticket/4150)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE QuasiQuotes #-} | |
module BadQQCPP where | |
import Language.Haskell.TH | |
import Language.Haskell.TH.Syntax | |
import Language.Haskell.TH.Quote | |
quoter :: QuasiQuoter | |
quoter = QuasiQuoter { quoteExp = lift } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE CPP, QuasiQuotes #-} | |
{-# OPTIONS_GHC -fdefer-type-errors #-} | |
module BadQQCPPMain where | |
import BadQQCPP | |
foo :: String | |
foo = "bar" | |
main :: IO () | |
main = putStrLn [quoter| | |
#include "BadQQCPP.hs" | |
|] | |
other :: IO () | |
other = putStrLn (1::Int) | |
{- Code above generates the following warning, despite occurring on line 16 - | |
BadQQCPPMain.hs:28:19: Warning: | |
Couldn't match type ‘Int’ with ‘[Char]’ | |
Expected type: String | |
Actual type: Int | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment