exon: Customizable quasiquote interpolation

[ library, string ] [ Propose Tags ]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.1.0, 0.2.0.0, 0.2.0.1, 0.3.0.0, 0.4.0.0, 0.5.0.0, 1.0.0.0, 1.0.0.1, 1.0.0.2, 1.0.1.0, 1.1.0.0, 1.2.0.0, 1.3.0.0, 1.4.0.0, 1.5.0.0, 1.5.0.1, 1.6.0.0, 1.6.0.1, 1.6.0.2, 1.6.1.0, 1.6.1.1 (info)
Change log changelog.md
Dependencies base (>=4 && <5), ghc, incipit-base (>=0.4 && <0.6), parsec, template-haskell [details]
License BSD-2-Clause-Patent
Copyright 2023 Torsten Schmits
Author Torsten Schmits
Maintainer hackage@tryp.io
Revised Revision 1 made by tek at 2023-12-29T18:00:55Z
Category String
Home page https://github.com/tek/exon#readme
Bug tracker https://github.com/tek/exon/issues
Source repo head: git clone https://github.com/tek/exon
Uploaded by tek at 2023-11-15T02:26:50Z
Distributions LTSHaskell:1.6.1.1, NixOS:1.6.1.1, Stackage:1.6.1.1
Reverse Dependencies 15 direct, 6 indirect [details]
Downloads 1142 total (60 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-1.6.1.0

[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}|]