BSD-2-Clause-Patent licensed by Torsten Schmits
Maintained by [email protected]
This version can be pinned in stack with:exon-1.6.1.1@sha256:604db8b8d3abd68a8bb116ae0ccb1d3d420bfe052beaa2ed3243fbb1465902ec,5338

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

Changes

1.6.0.0

  • Replace flatparse with parsec for less friction when updating GHC.

1.5.0.0

  • Use exonProcess for intercalate
  • Add intercalate1 for NonEmpty

1.2.0.0

  • Add class ExonExpression, allowing customization of how interpolated expressions are converted to builders. The method exonExpression is provided with the function exonBuilder as an argument to avoid having to depend on the class manually.
  • Change multi-method classes to use the default-method implementation style for the overlappable instance.

1.1.0.0

  • Add exonConcat to ExonAppend. The function is pulled out of exonBuild to allow using a different way of folding the segment list.

1.0.0.0

  • Rewrite the main logic, splitting it across multiple classes.
  • Automatically unwrap Generic newtype segments.
  • Use builders like Text.Builder, unwrapping Generic newtypes of the result type.
  • Don’t treat whitespace as special in the default quoter.

0.2.0.0

  • Add exonws, a variant that preserves whitespace.
  • Add exonWith, a constructor for custom quasiquoters.

0.1.1.0

  • Add Exon instance for String -> String, used by showsPrec.