Copyright | (c) Fumiaki Kinoshita 2019 |
---|---|
License | BSD3 |
Maintainer | Fumiaki Kinoshita <fumiexcel@gmail.com> |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- type Builder = forall s. Buildable s => BuilderFor s
- data BuilderFor s
- class Buildable s
- toStrictByteString :: BuilderFor GrowingBuffer -> ByteString
- toLazyByteString :: BuilderFor Channel -> ByteString
- hPutBuilderLen :: Handle -> BuilderFor PutBuilderEnv -> IO Int
- hPutBuilder :: Handle -> BuilderFor PutBuilderEnv -> IO ()
- sendBuilder :: Socket -> BuilderFor SocketEnv -> IO Int
- flush :: Buildable s => BuilderFor s
- encodeUtf8Builder :: Text -> Builder
- encodeUtf8BuilderEscaped :: BoundedPrim Word8 -> Text -> Builder
- byteString :: Buildable s => ByteString -> BuilderFor s
- lazyByteString :: ByteString -> Builder
- shortByteString :: ShortByteString -> Builder
- int8 :: Int8 -> Builder
- word8 :: Word8 -> Builder
- int16LE :: Int16 -> Builder
- int32LE :: Int32 -> Builder
- int64LE :: Int64 -> Builder
- word16LE :: Word16 -> Builder
- word32LE :: Word32 -> Builder
- word64LE :: Word64 -> Builder
- floatLE :: Float -> Builder
- doubleLE :: Double -> Builder
- int16BE :: Int16 -> Builder
- int32BE :: Int32 -> Builder
- int64BE :: Int64 -> Builder
- word16BE :: Word16 -> Builder
- word32BE :: Word32 -> Builder
- word64BE :: Word64 -> Builder
- floatBE :: Float -> Builder
- doubleBE :: Double -> Builder
- char7 :: Char -> Builder
- string7 :: String -> Builder
- char8 :: Char -> Builder
- string8 :: String -> Builder
- charUtf8 :: Char -> Builder
- stringUtf8 :: String -> Builder
- floatDec :: Float -> Builder
- doubleDec :: Double -> Builder
- word8Dec :: Word8 -> Builder
- word16Dec :: Word16 -> Builder
- word32Dec :: Word32 -> Builder
- word64Dec :: Word64 -> Builder
- wordDec :: Word -> Builder
- int8Dec :: Int8 -> Builder
- int16Dec :: Int16 -> Builder
- int32Dec :: Int32 -> Builder
- int64Dec :: Int64 -> Builder
- intDec :: Int -> Builder
- integerDec :: Integer -> Builder
- word8Hex :: Word8 -> Builder
- word16Hex :: Word16 -> Builder
- word32Hex :: Word32 -> Builder
- word64Hex :: Word64 -> Builder
- wordHex :: Word -> Builder
- int8HexFixed :: Int8 -> Builder
- int16HexFixed :: Int16 -> Builder
- int32HexFixed :: Int32 -> Builder
- int64HexFixed :: Int64 -> Builder
- word8HexFixed :: Word8 -> Builder
- word16HexFixed :: Word16 -> Builder
- word32HexFixed :: Word32 -> Builder
- word64HexFixed :: Word64 -> Builder
- floatHexFixed :: Float -> Builder
- doubleHexFixed :: Double -> Builder
- byteStringHex :: ByteString -> Builder
- lazyByteStringHex :: ByteString -> Builder
- primFixed :: FixedPrim a -> a -> Builder
- primBounded :: BoundedPrim a -> a -> Builder
- lengthPrefixedWithin :: Int -> BoundedPrim Int -> BuilderFor () -> Builder
Documentation
type Builder = forall s. Buildable s => BuilderFor s Source #
The Builder type. Requires RankNTypes extension
data BuilderFor s Source #
Builder specialised for a backend
Instances
Buildable s => IsString (BuilderFor s) Source # | |
Defined in Mason.Builder.Internal fromString :: String -> BuilderFor s # | |
Semigroup (BuilderFor s) Source # | |
Defined in Mason.Builder.Internal (<>) :: BuilderFor s -> BuilderFor s -> BuilderFor s # sconcat :: NonEmpty (BuilderFor s) -> BuilderFor s # stimes :: Integral b => b -> BuilderFor s -> BuilderFor s # | |
Monoid (BuilderFor a) Source # | |
Defined in Mason.Builder.Internal mempty :: BuilderFor a # mappend :: BuilderFor a -> BuilderFor a -> BuilderFor a # mconcat :: [BuilderFor a] -> BuilderFor a # |
This class is used to provide backend-specific operations for running a Builder
.
Instances
Buildable () Source # | Work with a constant buffer. |
Defined in Mason.Builder.Internal byteString :: ByteString -> BuilderFor () Source # flush :: BuilderFor () Source # allocate :: Int -> BuilderFor () Source # | |
Buildable SocketEnv Source # | |
Defined in Mason.Builder.Internal | |
Buildable PutBuilderEnv Source # | |
Defined in Mason.Builder.Internal | |
Buildable Channel Source # | |
Defined in Mason.Builder.Internal | |
Buildable GrowingBuffer Source # | |
Defined in Mason.Builder.Internal |
Runners
toStrictByteString :: BuilderFor GrowingBuffer -> ByteString Source #
Create a strict ByteString
toLazyByteString :: BuilderFor Channel -> ByteString Source #
Create a lazy ByteString
. Threaded runtime is required.
hPutBuilderLen :: Handle -> BuilderFor PutBuilderEnv -> IO Int Source #
Write a Builder
into a handle and obtain the number of bytes written.
flush
does not imply actual disk operations. Set NoBuffering
if you want
it to write the content immediately.
hPutBuilder :: Handle -> BuilderFor PutBuilderEnv -> IO () Source #
sendBuilder :: Socket -> BuilderFor SocketEnv -> IO Int Source #
Write a Builder
into a handle and obtain the number of bytes written.
Raw
flush :: Buildable s => BuilderFor s Source #
Flush the content of the internal buffer.
encodeUtf8BuilderEscaped :: BoundedPrim Word8 -> Text -> Builder Source #
Encode Text
with a custom escaping function
byteString :: Buildable s => ByteString -> BuilderFor s Source #
Put a ByteString
.
lazyByteString :: ByteString -> Builder Source #
Combine chunks of a lazy ByteString
shortByteString :: ShortByteString -> Builder Source #
Copy a ShortByteString
to a buffer.
int8Dec :: Int8 -> Builder Source #
Decimal encoding of an Int8
using the ASCII digits.
e.g.
toLazyByteString (int8Dec 42) = "42" toLazyByteString (int8Dec (-1)) = "-1"
integerDec :: Integer -> Builder Source #
Decimal encoding of an Integer
using the ASCII digits.
Simon Meier's improved implementation from https://github.com/haskell/bytestring/commit/92f19a5d94761042b44a433d7331107611e4d717
word8Hex :: Word8 -> Builder Source #
Shortest hexadecimal encoding of a Word8
using lower-case characters.
word16Hex :: Word16 -> Builder Source #
Shortest hexadecimal encoding of a Word16
using lower-case characters.
word32Hex :: Word32 -> Builder Source #
Shortest hexadecimal encoding of a Word32
using lower-case characters.
word64Hex :: Word64 -> Builder Source #
Shortest hexadecimal encoding of a Word64
using lower-case characters.
wordHex :: Word -> Builder Source #
Shortest hexadecimal encoding of a Word
using lower-case characters.
byteStringHex :: ByteString -> Builder Source #
Encode each byte of a ByteString
using its fixed-width hex encoding.
lazyByteStringHex :: ByteString -> Builder Source #
Encode each byte of a lazy ByteString
using its fixed-width hex encoding.
Advanced
primBounded :: BoundedPrim a -> a -> Builder Source #
Use BoundedPrim
:: Int | maximum length |
-> BoundedPrim Int | prefix encoder |
-> BuilderFor () | |
-> Builder |
Run a builder within a buffer and prefix it by the length.