Skip to content

Instantly share code, notes, and snippets.

@carymrobbins
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carymrobbins/8345cdcf7830fd6b1a6e to your computer and use it in GitHub Desktop.
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)
{-# 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 }
{-# 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