string-interpolate-0.3.4.0: Haskell string/text/bytestring interpolation that just works

Copyright | (c) William Yao 2019-2020
License | BSD-3
Maintainer | williamyaoh@gmail.com
Stability | experimental
Portability | POSIX
Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.String.Interpolate.Conversion

Contents

- Orphan instances

Description

Synopsis

- type family IsCustomSink dst :: Bool where ...
- class IsCustomSink dst ~ flag => InterpSink (flag :: Bool) dst where
  - type Builder (flag :: Bool) dst
  - ofString :: Proxy flag -> String -> B dst (Builder flag dst)
  - build :: Proxy flag -> B dst (Builder flag dst) -> B dst (Builder flag dst) -> B dst (Builder flag dst)
  - finalize :: Proxy flag -> B dst (Builder flag dst) -> dst
- 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
- encodeCharUTF8 :: Char -> Builder
- proxyWrapper :: forall final (flag :: Bool). IsCustomSink final ~ flag => (Proxy flag -> final) -> final

# Documentation

type family IsCustomSink dst :: Bool where ... Source #

Does this type require special behavior when something is interpolated into it?

Equations

IsCustomSink Text = 'True |
IsCustomSink Text = 'True |
IsCustomSink Builder = 'True |
IsCustomSink ByteString = 'True |
IsCustomSink ByteString = 'True |
IsCustomSink Builder = 'True |
IsCustomSink _1 = 'False |

class IsCustomSink dst ~ flag => InterpSink (flag :: Bool) dst where Source #

Something that can be interpolated into.

Associated Types

type Builder (flag :: Bool) dst Source #

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

Instances details

(IsCustomSink str ~ 'False, IsString str) => InterpSink 'False str Source # |

Instance details

Defined in Data.String.Interpolate.Conversion

Associated Types

type Builder 'False str |
Instance details Defined in Data.String.Interpolate.Conversion type Builder 'False str = ShowS

Methods

ofString :: Proxy 'False -> String -> B str (Builder 'False str) Source #

build :: Proxy 'False -> B str (Builder 'False str) -> B str (Builder 'False str) -> B str (Builder 'False str) Source #

finalize :: Proxy 'False -> B str (Builder 'False str) -> str Source #

InterpSink 'True Builder Source # |

Instance details

Defined in Data.String.Interpolate.Conversion.ByteStringSink

Associated Types

type Builder 'True Builder |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink type Builder 'True Builder = Builder

Methods

ofString :: Proxy 'True -> String -> B Builder (Builder 'True Builder) Source #

build :: Proxy 'True -> B Builder (Builder 'True Builder) -> B Builder (Builder 'True Builder) -> B Builder (Builder 'True Builder) Source #

finalize :: Proxy 'True -> B Builder (Builder 'True Builder) -> Builder Source #

InterpSink 'True ByteString Source # |

Instance details

Defined in Data.String.Interpolate.Conversion.ByteStringSink

Associated Types

type Builder 'True ByteString |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink type Builder 'True ByteString = ByteString

Methods

ofString :: Proxy 'True -> String -> B ByteString (Builder 'True ByteString) Source #

build :: Proxy 'True -> B ByteString (Builder 'True ByteString) -> B ByteString (Builder 'True ByteString) -> B ByteString (Builder 'True ByteString) Source #

finalize :: Proxy 'True -> B ByteString (Builder 'True ByteString) -> ByteString Source #

InterpSink 'True ByteString Source # |

Instance details

Defined in Data.String.Interpolate.Conversion.ByteStringSink

Associated Types

type Builder 'True ByteString |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink type Builder 'True ByteString = ByteString

Methods

ofString :: Proxy 'True -> String -> B ByteString (Builder 'True ByteString) Source #

build :: Proxy 'True -> B ByteString (Builder 'True ByteString) -> B ByteString (Builder 'True ByteString) -> B ByteString (Builder 'True ByteString) Source #

finalize :: Proxy 'True -> B ByteString (Builder 'True ByteString) -> ByteString Source #

InterpSink 'True Text Source # |

Instance details

Defined in Data.String.Interpolate.Conversion.TextSink

Associated Types

type Builder 'True Text |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink type Builder 'True Text = Text

Methods

ofString :: Proxy 'True -> String -> B Text (Builder 'True Text) Source #

build :: Proxy 'True -> B Text (Builder 'True Text) -> B Text (Builder 'True Text) -> B Text (Builder 'True Text) Source #

finalize :: Proxy 'True -> B Text (Builder 'True Text) -> Text Source #

InterpSink 'True Builder Source # |

Instance details

Defined in Data.String.Interpolate.Conversion.TextSink

Associated Types

type Builder 'True Builder |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink type Builder 'True Builder = Builder

Methods

ofString :: Proxy 'True -> String -> B Builder (Builder 'True Builder) Source #

build :: Proxy 'True -> B Builder (Builder 'True Builder) -> B Builder (Builder 'True Builder) -> B Builder (Builder 'True Builder) Source #

finalize :: Proxy 'True -> B Builder (Builder 'True Builder) -> Builder Source #

InterpSink 'True Text Source # |

Instance details

Defined in Data.String.Interpolate.Conversion.TextSink

Associated Types

type Builder 'True Text |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink type Builder 'True Text = Text

Methods

ofString :: Proxy 'True -> String -> B Text (Builder 'True Text) Source #

build :: Proxy 'True -> B Text (Builder 'True Text) -> B Text (Builder 'True Text) -> B Text (Builder 'True Text) Source #

finalize :: Proxy 'True -> B Text (Builder 'True Text) -> Text Source #

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.

Methods

interpolate :: Proxy flag -> src -> B dst (Builder flag dst) Source #

#### Instances

Instances details

(IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False Builder dst Source # |
Instance details Defined in Data.String.Interpolate.Conversion Methods interpolate :: Proxy 'False -> Builder -> B dst (Builder 'False dst) Source #
(IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False ByteString dst Source # |
Instance details Defined in Data.String.Interpolate.Conversion Methods interpolate :: Proxy 'False -> ByteString -> B dst (Builder 'False dst) Source #
(IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False ByteString dst Source # |
Instance details Defined in Data.String.Interpolate.Conversion Methods interpolate :: Proxy 'False -> ByteString -> B dst (Builder 'False dst) Source #
(IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False Text dst Source # |
Instance details Defined in Data.String.Interpolate.Conversion Methods interpolate :: Proxy 'False -> Text -> B dst (Builder 'False dst) Source #
(IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False Builder dst Source # |
Instance details Defined in Data.String.Interpolate.Conversion Methods interpolate :: Proxy 'False -> Builder -> B dst (Builder 'False dst) Source #
(IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False Text dst Source # |
Instance details Defined in Data.String.Interpolate.Conversion Methods interpolate :: Proxy 'False -> Text -> B dst (Builder 'False dst) Source #
(IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False String dst Source # |
Instance details Defined in Data.String.Interpolate.Conversion Methods interpolate :: Proxy 'False -> String -> B dst (Builder 'False dst) Source #
(IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False Char dst Source # |
Instance details Defined in Data.String.Interpolate.Conversion Methods interpolate :: Proxy 'False -> Char -> B dst (Builder 'False dst) Source #
(Show src, IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False src dst Source # |
Instance details Defined in Data.String.Interpolate.Conversion Methods interpolate :: Proxy 'False -> src -> B dst (Builder 'False dst) Source #
Interpolatable 'True Builder Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> Builder -> B Builder (Builder 'True Builder) Source #
Interpolatable 'True Builder ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> Builder -> B ByteString (Builder 'True ByteString) Source #
Interpolatable 'True Builder ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> Builder -> B ByteString (Builder 'True ByteString) Source #
Interpolatable 'True Builder Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> Builder -> B Text (Builder 'True Text) Source #
Interpolatable 'True Builder Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> Builder -> B Builder (Builder 'True Builder) Source #
Interpolatable 'True Builder Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> Builder -> B Text (Builder 'True Text) Source #
Interpolatable 'True ByteString Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> ByteString -> B Builder (Builder 'True Builder) Source #
Interpolatable 'True ByteString ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> ByteString -> B ByteString (Builder 'True ByteString) Source #
Interpolatable 'True ByteString ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> ByteString -> B ByteString (Builder 'True ByteString) Source #
Interpolatable 'True ByteString Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> ByteString -> B Text (Builder 'True Text) Source #
Interpolatable 'True ByteString Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> ByteString -> B Builder (Builder 'True Builder) Source #
Interpolatable 'True ByteString Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> ByteString -> B Text (Builder 'True Text) Source #
Interpolatable 'True ByteString Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> ByteString -> B Builder (Builder 'True Builder) Source #
Interpolatable 'True ByteString ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> ByteString -> B ByteString (Builder 'True ByteString) Source #
Interpolatable 'True ByteString ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> ByteString -> B ByteString (Builder 'True ByteString) Source #
Interpolatable 'True ByteString Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> ByteString -> B Text (Builder 'True Text) Source #
Interpolatable 'True ByteString Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> ByteString -> B Builder (Builder 'True Builder) Source #
Interpolatable 'True ByteString Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> ByteString -> B Text (Builder 'True Text) Source #
Interpolatable 'True Text Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> Text -> B Builder (Builder 'True Builder) Source #
Interpolatable 'True Text ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> Text -> B ByteString (Builder 'True ByteString) Source #
Interpolatable 'True Text ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> Text -> B ByteString (Builder 'True ByteString) Source #
Interpolatable 'True Text Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> Text -> B Text (Builder 'True Text) Source #
Interpolatable 'True Text Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> Text -> B Builder (Builder 'True Builder) Source #
Interpolatable 'True Text Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> Text -> B Text (Builder 'True Text) Source #
Interpolatable 'True Builder Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> Builder -> B Builder (Builder 'True Builder) Source #
Interpolatable 'True Builder ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> Builder -> B ByteString (Builder 'True ByteString) Source #
Interpolatable 'True Builder ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> Builder -> B ByteString (Builder 'True ByteString) Source #
Interpolatable 'True Builder Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> Builder -> B Text (Builder 'True Text) Source #
Interpolatable 'True Builder Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> Builder -> B Builder (Builder 'True Builder) Source #
Interpolatable 'True Builder Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> Builder -> B Text (Builder 'True Text) Source #
Interpolatable 'True Text Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> Text -> B Builder (Builder 'True Builder) Source #
Interpolatable 'True Text ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> Text -> B ByteString (Builder 'True ByteString) Source #
Interpolatable 'True Text ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> Text -> B ByteString (Builder 'True ByteString) Source #
Interpolatable 'True Text Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> Text -> B Text (Builder 'True Text) Source #
Interpolatable 'True Text Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> Text -> B Builder (Builder 'True Builder) Source #
Interpolatable 'True Text Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> Text -> B Text (Builder 'True Text) Source #
Interpolatable 'True String Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> String -> B Builder (Builder 'True Builder) Source #
Interpolatable 'True String ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> String -> B ByteString (Builder 'True ByteString) Source #
Interpolatable 'True String ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> String -> B ByteString (Builder 'True ByteString) Source #
Interpolatable 'True String Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> String -> B Text (Builder 'True Text) Source #
Interpolatable 'True String Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> String -> B Builder (Builder 'True Builder) Source #
Interpolatable 'True String Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> String -> B Text (Builder 'True Text) Source #
Interpolatable 'True Char Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> Char -> B Builder (Builder 'True Builder) Source #
Interpolatable 'True Char ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> Char -> B ByteString (Builder 'True ByteString) Source #
Interpolatable 'True Char ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> Char -> B ByteString (Builder 'True ByteString) Source #
Interpolatable 'True Char Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> Char -> B Text (Builder 'True Text) Source #
Interpolatable 'True Char Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> Char -> B Builder (Builder 'True Builder) Source #
Interpolatable 'True Char Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> Char -> B Text (Builder 'True Text) Source #
Show src => Interpolatable 'True src Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> src -> B Builder (Builder 'True Builder) Source #
Show src => Interpolatable 'True src ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> src -> B ByteString (Builder 'True ByteString) Source #
Show src => Interpolatable 'True src ByteString Source # |
Instance details Defined in Data.String.Interpolate.Conversion.ByteStringSink Methods interpolate :: Proxy 'True -> src -> B ByteString (Builder 'True ByteString) Source #
Show src => Interpolatable 'True src Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> src -> B Text (Builder 'True Text) Source #
Show src => Interpolatable 'True src Builder Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> src -> B Builder (Builder 'True Builder) Source #
Show src => Interpolatable 'True src Text Source # |
Instance details Defined in Data.String.Interpolate.Conversion.TextSink Methods interpolate :: Proxy 'True -> src -> B Text (Builder 'True Text) Source #

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).

encodeCharUTF8 :: Char -> Builder Source #

Data.ByteString.Builder provides `charUtf8` to do this, but it doesn't correctly handle invalid characters.

proxyWrapper :: forall final (flag :: Bool). IsCustomSink final ~ flag => (Proxy flag -> final) -> final Source #

Used to indicate to GHC that the value of all the proxy arguments is the same.

# Orphan instances

(IsCustomSink str ~ 'False, IsString str) => InterpSink 'False str Source # |

Instance details

Associated Types

type Builder 'False str |
Instance details Defined in Data.String.Interpolate.Conversion type Builder 'False str = ShowS

Methods

ofString :: Proxy 'False -> String -> B str (Builder 'False str) Source #

build :: Proxy 'False -> B str (Builder 'False str) -> B str (Builder 'False str) -> B str (Builder 'False str) Source #

finalize :: Proxy 'False -> B str (Builder 'False str) -> str Source #

(IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False Builder dst Source # |
Instance details Methods interpolate :: Proxy 'False -> Builder -> B dst (Builder 'False dst) Source #
(IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False ByteString dst Source # |
Instance details Methods interpolate :: Proxy 'False -> ByteString -> B dst (Builder 'False dst) Source #
(IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False ByteString dst Source # |
Instance details Methods interpolate :: Proxy 'False -> ByteString -> B dst (Builder 'False dst) Source #
(IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False Text dst Source # |
Instance details Methods interpolate :: Proxy 'False -> Text -> B dst (Builder 'False dst) Source #
(IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False Builder dst Source # |
Instance details Methods interpolate :: Proxy 'False -> Builder -> B dst (Builder 'False dst) Source #
(IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False Text dst Source # |
Instance details Methods interpolate :: Proxy 'False -> Text -> B dst (Builder 'False dst) Source #
(IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False String dst Source # |
Instance details Methods interpolate :: Proxy 'False -> String -> B dst (Builder 'False dst) Source #
(IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False Char dst Source # |
Instance details Methods interpolate :: Proxy 'False -> Char -> B dst (Builder 'False dst) Source #
(Show src, IsString dst, IsCustomSink dst ~ 'False) => Interpolatable 'False src dst Source # |
Instance details Methods interpolate :: Proxy 'False -> src -> B dst (Builder 'False dst) Source #