Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module reexports all the relevant tools of the custom-interpolation
package.
Synopsis
- interpolateQQ :: InterpolationConfig a -> QuasiQuoter
- interpolate :: InterpolationConfig a -> String -> Q Exp
- data InterpolationConfig a = InterpolationConfig {}
- simpleConfig :: InterpolationConfig ()
- defaultConfig :: InterpolationConfig a
- data Interpolator a = Interpolator {}
- type Prefix = String
- simpleInterpolator :: Interpolator ()
- applyInterpolator :: Monoid a => Q Exp -> Interpolator a
- data Brackets = Brackets {}
- curlyBrackets :: Brackets
- roundBrackets :: Brackets
- squareBrackets :: Brackets
- angleBrackets :: Brackets
Template Haskell
The main entry points of the library. Use these to build your template haskell functions and quasiquoters.
interpolateQQ :: InterpolationConfig a -> QuasiQuoter Source #
Create a new QuasiQuoter
that interpolates strings as specified by the given InterpolationConfig
.
interpolate :: InterpolationConfig a -> String -> Q Exp Source #
Interpolate a string as specified by the given InterpolationConfig
.
Configuration
data InterpolationConfig a Source #
Rules for interpolating a string.
InterpolationConfig | |
|
Instances
Default (InterpolationConfig a) Source # |
|
Defined in CustomInterpolation.Config def :: InterpolationConfig a # |
simpleConfig :: InterpolationConfig () Source #
Type-restricted simple version of defaultConfig
.
Use this if you just want to substitute interpolated segments with a string expression.
defaultConfig :: InterpolationConfig a Source #
Default InterpolationConfig
.
Has no handlers
, finalize
ignores any extra values returned when interpolating and escape
does nothing.
Interpolators
data Interpolator a Source #
Interpolator | |
|
Interpolator Helpers
Constructors for common Interpolator
s.
simpleInterpolator :: Interpolator () Source #
Default Interpolator
.
Inserts the interpolated expression as is and uses curlyBrackets
with no prefix
.
applyInterpolator :: Monoid a => Q Exp -> Interpolator a Source #
Create an Interpolator
that applies a quoted function to the interpolated expression. Uses curlyBrackets
and no prefix
.
Example
>>>
$(interpolate (simpleConfig {handlers = [applyInterpolator [|show . (^ 2)|]]}) "two squared equals {2}")
"two squared equals 4"
Brackets
curlyBrackets :: Brackets Source #
{}
roundBrackets :: Brackets Source #
()
squareBrackets :: Brackets Source #
[]
angleBrackets :: Brackets Source #
<>