BSD-2-Clause-Patent licensed by Torsten Schmits
Maintained by [email protected]
This version can be pinned in stack with:exon-1.7.0.0@sha256:b6ed6842f34a995ccd7e7f8910603478716b21d04eb231211f9c38bfb21b4d04,5697

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.