Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- exonError :: ToString e => MonadFail m => e -> m a
- segmentsQ :: QOrIO m => String -> m (NonEmpty RawSegment)
- class Quasi m => QOrIO (m :: Type -> Type) where
- fileExtensions :: m [Extension]
- reifyExp :: QOrIO m => String -> m Exp
- reifySegments :: QOrIO m => NonEmpty RawSegment -> m (NonEmpty Exp)
- quoteExpWith :: QOrIO m => Q Type -> String -> m Exp
- quoteExp :: QOrIO m => String -> m Exp
- exonWith :: Q Type -> QuasiQuoter
- exon :: QuasiQuoter
- exonws :: QuasiQuoter
Documentation
class Quasi m => QOrIO (m :: Type -> Type) where Source #
fileExtensions :: m [Extension] Source #
Instances
QOrIO IO Source # | |
Defined in Exon.Quote fileExtensions :: IO [Extension] Source # | |
QOrIO Q Source # | |
Defined in Exon.Quote fileExtensions :: Q [Extension] Source # |
reifySegments :: QOrIO m => NonEmpty RawSegment -> m (NonEmpty Exp) Source #
exonWith :: Q Type -> QuasiQuoter Source #
Constructor for a quasiquoter for an arbitrary tag.
This can be used to define quoters with custom logic, requiring an instance of Exon
for the given type:
>>>
import Exon.Class.Exon (Exon(..))
>>>
import Exon.Data.Segment (Segment(String))
>>>
data Nl
>>>
instance (Monoid a, IsString a) => Exon Nl a where insertWhitespace s1 _ s2 = appendSegment @Nl (appendSegment @Nl s1 (String "\n")) s2
>>>
exonnl = exonWith [t|Nl|]
>>>
[exonnl|one two three|]
"one\ntwo\nthree"
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
"xyz"
This behavior can be customized by writing an instance of Exon
.
exonws :: QuasiQuoter Source #
A variant of exon
that always keeps whitespace verbatim.