exon: Customizable Quasiquote Interpolation

[ library, string ] [ Propose Tags ]
This version is deprecated.
Versions [RSS],,,,,,,,,,,,,,,,,,,,,, (info)
Change log changelog.md
Dependencies base (>=4.12 && <5), flatparse (>=, generics-sop (>=, ghc-hs-meta (>=0.1), incipit-base (>=0.2), template-haskell, type-errors-pretty (>= [details]
License BSD-2-Clause-Patent
Copyright 2022 Torsten Schmits
Author Torsten Schmits
Maintainer hackage@tryp.io
Category String
Home page https://git.tryp.io/tek/exon
Bug tracker https://git.tryp.io/tek/exon/issues
Source repo head: git clone https://git.tryp.io/tek/exon
Uploaded by tek at 2022-09-09T22:15:28Z
Distributions LTSHaskell:, NixOS:, Stackage:
Reverse Dependencies 15 direct, 6 indirect [details]
Downloads 1286 total (106 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for exon-

[back to package description]

This Haskell library provides string interpolation in quasiquotes, allowing you to build strings like this:

animal = "snake"
location = "a tree"
[exon|#{animal} in #{location}|]
-- "snake in a tree"

Each step of the process is customizable based on the result type of the quote, making it possible to construct strings for arbitrary types. For example, String -> String is the type used by showsPrec, which can be a bit of a hassle to write:

data Record =
  Record {
    number :: Int,
    maybeNumber :: Maybe Int,
    value :: Value

instance Show Record where
  showsPrec d Record {..} =
    showParen (d > 10) [exon|Record #{showsPrec 11 number} #{showsPrec 11 maybeNumber} #{showsPrec 11 value}|]