Flexible production-scale string interpolation library.
We wanted a solution that would
- Use efficient
Buildable
andFromBuildable
by default, but would allow usingShow
if necessary too. - Have numerious switches: indentation stripping, spaces trimming, result preview, and more.
- Have two variations:
- Full-fledged interpolator, but with a heavy
haskell-src-exts
dependency; - Light-weight interpolator that interpolates only variables, but not arbitrary expressions.
- Full-fledged interpolator, but with a heavy
- Have convenient defaults, that both can be overriden at use site and customized in the quasi-quoter.
- It is still possible to use
Show
as default; - Default set of switches can be changed to suit your preferences.
- It is still possible to use
The usage looks like:
import Text.Interpolation.Nyan
myText :: Text
myText =
let val = 5 :: Int
[int|s| Value is #{val} |]
-- "Value is 5"
myMultilineText :: Text
myMultilineText =
[int||
What would you get if you fix a cat and a rainbow?
And a cookie?
|]
-- "What would you get if you fix a cat and a rainbow?\nAnd a cockie?\n"
The full introduction can be found in the haddock documentation.
This repository contains the following haskell packages:
full
contains the basic interpolator and corresponds to thenyan-interpolation
library;core
provides means for defining custom interpolators and corresponds to thenyan-interpolation-core
library;simple
contains the lightweight interpolator and corresponds to thenyan-interpolation-simple
library.
We provide snippets, and syntax highlighting is yet to be implemented (see #3).
Please see CONTRIBUTING.md for more information.
Nyan-interpolation is maintained and funded with ❤️ by Serokell. The names and logo for Serokell are trademark of Serokell OÜ.
We love open source software! See our other projects or hire us to design, develop and grow your idea!