Opened 4 years ago

Closed 4 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 Revisions:

Description

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 4 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  [email protected]
  * Add quoteFile function (see Trac #4293)

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

comment:2 Changed 4 years ago by simonpj

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.