| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.String.Interpolate.Conversion
Synopsis
- newtype B dst a = B {
- unB :: a
- type family IsCustomSink dst where ...
- class IsCustomSink dst ~ flag => InterpSink (flag :: Bool) dst where
- class InterpSink flag dst => Interpolatable (flag :: Bool) src dst where
- interpolate :: Proxy flag -> src -> B dst (Builder flag dst)
- bsToTextBuilder :: ByteString -> Builder
- lbsToTextBuilder :: ByteString -> Builder
Documentation
We wrap the builders in B so that we can add a phantom type parameter.
This gives the inner interpolates enough information to know where
they're going and pick an instance, forcing all the types into lockstep.
type family IsCustomSink dst where ... Source #
Does this type require special behavior when something is interpolated into it?
Equations
| IsCustomSink Text = True | |
| IsCustomSink Text = True | |
| IsCustomSink ByteString = True | |
| IsCustomSink ByteString = True | |
| IsCustomSink _ = False |
class IsCustomSink dst ~ flag => InterpSink (flag :: Bool) dst where Source #
Something that can be interpolated into.
Methods
ofString :: Proxy flag -> String -> B dst (Builder flag dst) Source #
Meant to be used only for verbatim parts of the interpolation.
build :: Proxy flag -> B dst (Builder flag dst) -> B dst (Builder flag dst) -> B dst (Builder flag dst) Source #
build should be 'in-order'; that is, the left builder comes from
a string on the left, and the right builder comes from a string on the right.
finalize :: Proxy flag -> B dst (Builder flag dst) -> dst Source #
Instances
class InterpSink flag dst => Interpolatable (flag :: Bool) src dst where Source #
Represents that we can interpolate objects of type src into a an interpolation string that returns type dst.
Instances
bsToTextBuilder :: ByteString -> Builder Source #
Convert a strict ByteString into a Text Builder, converting any invalid
characters into the Unicode replacement character � (U+FFFD).
lbsToTextBuilder :: ByteString -> Builder Source #
Convert a lazy ByteString into a Text Builder, converting any invalid
characters into the Unicode replacement character � (U+FFFD).