Opened 7 years ago

Closed 7 years ago

#4293 closed proposal (fixed)

Utility function for quasi-quoters: reading files

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


I just wrote a useful combinator for quasi-quoters, you may want to include it in the Quote module. It takes an existing quasi-quoter and produces a quasi-quoter that statically reads and parses the content of a file.

quotefile :: QuasiQuoter -> QuasiQuoter
quotefile (QuasiQuoter exp pat) = QuasiQuoter (ff exp) (ff pat) where
  ff old s = runIO (readFile s) >>= old

This is useful when you need to quote data from a separately maintained or generated source file.

Change History (2)

comment:1 Changed 7 years ago by simonpj

Seems useful, thank you. I've added it to the template-haskell library.

Fri Sep 10 09:20:16 BST 2010
  * Add quoteFile function (see Trac #4293)

    M ./Language/Haskell/TH/Quote.hs -1 +16

comment:2 Changed 7 years ago by simonpj

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.