binary-ext-2.0.4: An alternate with strong-typed errors for `Data.Binary.Get` monad from `binary` package.

Safe HaskellNone



Text generator. The PutM specialization for text output.



type PutM s i o m a = PutS s (ConduitT i o m) a Source #

A ConduitT with wrappers supposed to a binary or text serialization.

type TextGen = forall s i m. (DefaultTextGenState s, Monad m) => PutM s i Text m () Source #

The shortening of PutM for the most common use case of text serialization.

runTextGen :: PutM VoidEncodingState i o m () -> ConduitT i o m () Source #

Run an encoder presented as a PutM monad. Returns Producer.

genString :: Text -> TextGen Source #

Output a strict string.

genLazyString :: Text -> TextGen Source #

Output a string.

genShow :: Show a => a -> TextGen Source #

Output a showable object.

genDigit :: Integral a => a -> TextGen Source #

Output a decimal digit.

genHexDigit :: Integral a => Bool -> a -> TextGen Source #

Output a hexadecimal digit.

genHexByte :: Bool -> Word8 -> TextGen Source #

Output a byte as a hexadecimal digit pair.

genEnum :: (Eq a, Ord a, Enum a, Bounded a, Show a) => Int -> a -> TextGen Source #

Output an enum value.

For example, for

data CharKind = CharKindWhitespace | CharKindOrdinar deriving (Eq, Ord, Enum, Bounded, Show)

the following statement is true:

runConduitPure $ runTextGen (genEnum 8 CharKindWhitespace) .| sinkLazy = "Whitespace"