exon-0.1.0.0: Monoidal Quasiquote Interpolation
Safe HaskellNone
LanguageHaskell2010

Exon.Quote

Description

 
Synopsis

Documentation

exonError :: ToString e => MonadFail m => e -> m a Source #

class Quasi m => QOrIO (m :: Type -> Type) where Source #

Instances

Instances details
QOrIO IO Source # 
Instance details

Defined in Exon.Quote

QOrIO Q Source # 
Instance details

Defined in Exon.Quote

exon :: QuasiQuoter Source #

A quasiquoter that allows interpolation, concatenating the resulting segments monoidally.

>>> [exon|write #{show @Text (5 :: Int)} lines of code|] :: Text
"write 5 lines of code"

The default implementation for any non-stringly type uses IsString to construct the literal segments and mappend to combine them, ignoring whitespace segments.

>>> newtype Part = Part Text deriving newtype (Show, Semigroup, Monoid, IsString)
>>> [exon|x #{Part "y"}z|] :: Part
Part "xyz"

This behavior can be customized by writing an instance of Exon.