interpol alternatives and similar packages
Based on the "Language" category.
Alternatively, view interpol alternatives based on common mentions on social networks and blogs.
-
elm-compiler
Compiler for Elm, a functional language for reliable webapps. -
stylish-haskell
Haskell code prettifier [Moved to: https://github.com/haskell/stylish-haskell] -
haskell-src-exts
Manipulating Haskell source: abstract syntax, lexer, parser, and pretty-printer -
language-python
A parser for Python 2.x and 3.x written in Haskell -
nirum
Nirum: IDL compiler and RPC/distributed object framework for microservices -
tal
An implementation of Typed Assembly Language (Morrisett, Walker, Crary, Glew) -
language-c-quote
C/CUDA/OpenCL/Objective-C quasiquoting library. -
aterm-utils
Utility functions for working with aterms as generated by Minitermite -
language-ecmascript
Haskell library: ECMAScript parser, pretty-printer and additional tools -
ministg
Ministg is an interpreter for a high-level, small-step, operational semantics for the STG machine. -
purescript-tsd-gen
TypeScript Declaration File (.d.ts) generator for PureScript
Access the most powerful time series database as a service
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of interpol or a related project?
README
interpol
variable interpolations
Examples
The interpol
preprocessor 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).
Installation
This package is on Hackage. To install it, run:
cabal update
cabal install interpol
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 #-}
Note that, unless you use this latter pragma,
ghc-mod and other
flymake
-based Emacs modes will probably complain about unused
variables.
Operation
The interpol
preprocessor effectively does two things:
it adds an import declaration for
Text.Interpol
, in order to bring the(^-^)
operator into scope, andit replaces any occurrence of
"\\{[A-z_][A-z0-9_]*}"
in string literals with"^-^ <ident> ^-^"
.
So,
"I have {okVal} apples."
actually becomes
("I have " ^-^ okVal ^-^ " apples.")
The (^-^)
operator is a smarter version of (++)
: it shows its
second argument before appending, but only if it is not already a
String
(i.e. it does not quote String
values when interpolating).
Run the preprocessor manually and check out the source for details (seriously now, this README is longer than the source).