Opened 6 years ago

Closed 6 years ago

#5427 closed bug (wontfix)

'#' becomes an illegal first-character of a QuasiQuote line when CPP is enabled

Reported by: GregWeber Owned by:
Priority: normal Milestone:
Component: Template Haskell Version: 7.2.1
Keywords: Cc: michael@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


{-# LANGUAGE CPP #-} <pre> [hamlet| #{foo} |] </pre>

This will fail to compile. CPP should skip over a quasi-quote, which is allowed to have any characters. I think the only use case for CPP inside QQ is trying to place a QQ into an external file. In Yesod, we accomplish this with Template Haskell.

Our ideal situation would be for GHC to provide a function loadQQ. This would make it simple to not need #include. But my real hope is that loadQQ will identify the external file as a dependency and automatically recompile that code as needed.

Change History (2)

comment:1 Changed 6 years ago by GregWeber

Sorry, here is proper formatting for the example code

{-# LANGUAGE QuasiQuotes, CPP #-}

comment:2 Changed 6 years ago by igloo

Resolution: wontfix
Status: newclosed

When CPP is enabled, we just run cpp on the source code. cpp doesn't know anything about Haskell, so it can't ignore quasi-quoted content.

One option is to provide a way to escape '#'s in your quasi-quoter, so e.g. hamlet would parse


as if it were #{foo}.

Note: See TracTickets for help on using tickets.