See https://hackage.haskell.org/package/exon/docs/Exon.html


Keywords
string, Propose Tags, Report a vulnerability, https://hackage.haskell.org/package/exon/docs/Exon.html, Skip to Readme, Index, Quick Jump, Exon, Exon.Class.Exon, Exon.Class.Newtype, Exon.Class.ToSegment, Exon.Combinators, Exon.Data.RawSegment, Exon.Data.Result, Exon.Data.Segment, Exon.Generic, Exon.Haskell.Parse, Exon.Haskell.Settings, Exon.Haskell.Translate, Exon.Parse, Exon.Quote, Exon.SkipWs, exon-1.7.1.0.tar.gz, browse, Package description, Package maintainers, tek, edit package information , haskell, quasiquotes, string-interpolation
License
BSD-2-Clause-Patent
Install
cabal install exon-1.7.0.0

Documentation

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"

Please consult hackage for the full documentation.

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