@hackage exon1.7.3.0
Customizable quasiquote interpolation
Installation
Dependencies (5)
- base >=4.17.2.1 && <4.23
- ghc >=9.4.8 && <9.15
- incipit-base >=0.5.0.0 && <0.8
- parsec >=3.1.15.1 && <3.2
- template-haskell >=2.19.0.0 && <2.25 Show all…
Dependents (16)
@hackage/sqel, @hackage/ribosome-test, @hackage/ribosome-host, @hackage/proteome, @hackage/prelate, @hackage/polysemy-hasql, Show all…
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}|]