A quasiquoter for haskell-src-exts.
Haskell
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Language/Haskell/Exts
tests
.travis.yml
LICENSE
README.md
Setup.lhs
haskell-src-exts-qq.cabal
stack.yaml

README.md

haskell-src-exts-qq: quasiquote Haskell

Build Status Hackage

Write programs that generate Haskell programs much more concisely and legibly. This package supports:

  • Antiquotations, denoted by stealing the splice syntax of Template Haskell, for example:
    [hs| $x ++ $(Hs.strE "bar") |]

Splices may not nested.

  • Antiquoting pattern variables in patterns, using double parentheses. For instance:

    let x = Hs.name "n"
    in [hs| \ ((x)) -> $(Hs.Var (Hs.UnQual x)) + 1 |]
  • Antiquoting bound names. Names that are antiquoted appear surrounded by double underscores. For instance:

    let f = "incr"
        fE = Hs.Var $ Hs.UnQual $ Hs.name f
    in [hs| let __f__ x = x + 1 in $fE 10 |]

We need three different syntaxes for antiquotations, because we do not extend the haskell-src-exts parser in any way and the Template Haskell splicing syntax is only available in expression contexts.