The interpol package

[Tags: gpl, library, program]

This pre-processor enables variable interpolation in strings. See the README.md file for details.


[Skip to ReadMe]

Properties

Versions0.1.0, 0.2.0, 0.2.1, 0.2.2, 0.2.3
Change logNone available
Dependenciesbase (==4.*), preprocessor-tools, regex-posix, syb [details]
LicenseGPL
AuthorAlexandru Scvortov <scvalex@gmail.com>
Maintainerscvalex@gmail.com
Stabilityexperimental
CategorySource-tools, Language
Home pagehttps://github.com/scvalex/interpol
Executablesinterpol
UploadedThu Nov 3 22:33:53 UTC 2011 by AlexandruScvortov
Downloads753 total (37 in last 30 days)
Votes
0 []
StatusDocs not available [build log]
All reported builds failed as of 2015-06-02 [all 2 reports]

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for interpol-0.1.0

interpol

variable interpolations

Examples

The interpol pre-processor parses Haskell source file before GHC and performs variable interpolation statically. Concretely, it replaces {identifier} patterns in literal strings with show identifier. For instance,

okVal = 23
"I have {okVal} apples."

becomes

"I have 23 apples."

This works on any type that has a Show instance and is safe, in the sense that it does not disable any of GHC's normal checks (i.e. interpolating a non-existing identifier or one whose type does not have a Show instance will result in the appropriate error).

Usage

To use interpol, install the cabal package (and/or make sure that the interpol executable is in your path), and compile with the "-F -pgmF interpol" GHC options. For instance, one of the tests for this package is compiled with:

ghc -F -pgmF interpol Test/One.hs

Alternatively, you may specify the options in a GHC_OPTIONS pragma at the top of the file:

{-# OPTIONS_GHC -F -pgmF interpol #-}

Operation

The interpol pre-processor effectively replaces "\\{[A-z_][A-z0-9_]*}" with "++ show <ident> ++". So,

"I have {okVal} apples."

actually becomes

("I have " ++ show okVal ++ " apples.")

Run the pre-processor manually and check out the source for details (seriously now, this README is longer than the source).