-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Fast and extensible bytestring builder -- -- See README.md @package mason @version 0 module Mason.Builder.Internal -- | The Builder type. Requires RankNTypes extension type Builder = forall s. Buildable s => BuilderFor s -- | Builder specialised for a backend newtype BuilderFor s Builder :: (s -> Buffer -> IO Buffer) -> BuilderFor s [unBuilder] :: BuilderFor s -> s -> Buffer -> IO Buffer -- | This class is used to provide backend-specific operations for running -- a Builder. class Buildable s -- | Put a ByteString. byteString :: Buildable s => ByteString -> BuilderFor s -- | Flush the content of the internal buffer. flush :: Buildable s => BuilderFor s -- | Allocate a buffer with at least the given length. allocate :: Buildable s => Int -> BuilderFor s newtype GrowingBuffer GrowingBuffer :: IORef (ForeignPtr Word8) -> GrowingBuffer -- | Buffer pointers data Buffer Buffer :: {-# UNPACK #-} !Ptr Word8 -> {-# UNPACK #-} !Ptr Word8 -> Buffer -- | end of the buffer (next to the last byte) [bEnd] :: Buffer -> {-# UNPACK #-} !Ptr Word8 -- | current position [bCur] :: Buffer -> {-# UNPACK #-} !Ptr Word8 -- | Copy a ByteString to a buffer. byteStringCopy :: Buildable s => ByteString -> BuilderFor s -- | Copy a ShortByteString to a buffer. shortByteString :: ShortByteString -> Builder -- | Create a strict ByteString toStrictByteString :: BuilderFor GrowingBuffer -> ByteString data Channel Channel :: !MVar ByteString -> !IORef (ForeignPtr Word8) -> Channel [chResp] :: Channel -> !MVar ByteString [chBuffer] :: Channel -> !IORef (ForeignPtr Word8) -- | Create a lazy ByteString. Threaded runtime is required. toLazyByteString :: BuilderFor Channel -> ByteString -- | UTF-8 encode a String. stringUtf8 :: String -> Builder -- | Run a builder within a buffer and prefix it by the length. lengthPrefixedWithin :: Int -> BoundedPrim Int -> BuilderFor () -> Builder -- | Use BoundedPrim primBounded :: BoundedPrim a -> a -> Builder -- | Use FixedPrim primFixed :: FixedPrim a -> a -> Builder primMapListFixed :: FixedPrim a -> [a] -> Builder primMapListBounded :: BoundedPrim a -> [a] -> Builder primMapByteStringFixed :: FixedPrim Word8 -> ByteString -> Builder primMapLazyByteStringFixed :: FixedPrim Word8 -> ByteString -> Builder -- | 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. hPutBuilderLen :: Handle -> BuilderFor PutBuilderEnv -> IO Int -- | Environemnt for handle output data PutBuilderEnv PBE :: !Handle -> !IORef (ForeignPtr Word8) -> !IORef Int -> PutBuilderEnv [pbHandle] :: PutBuilderEnv -> !Handle [pbBuffer] :: PutBuilderEnv -> !IORef (ForeignPtr Word8) [pbTotal] :: PutBuilderEnv -> !IORef Int -- | Encode Text with a custom escaping function encodeUtf8BuilderEscaped :: BoundedPrim Word8 -> Text -> Builder -- | Write a Builder into a handle and obtain the number of bytes -- written. sendBuilder :: Socket -> BuilderFor SocketEnv -> IO Int -- | Environemnt for socket output data SocketEnv SE :: !Socket -> !IORef (ForeignPtr Word8) -> !IORef Int -> SocketEnv [seSocket] :: SocketEnv -> !Socket [seBuffer] :: SocketEnv -> !IORef (ForeignPtr Word8) [seCounter] :: SocketEnv -> !IORef Int cstring :: Ptr Word8 -> Builder cstringUtf8 :: Ptr Word8 -> Builder -- | Ensure that the given number of bytes is available in the buffer. -- Subject to semigroup fusions ensure :: Int -> (Buffer -> IO Buffer) -> Builder -- | Allocate a new buffer. allocateConstant :: (s -> IORef (ForeignPtr Word8)) -> Int -> BuilderFor s -- | Decimal encoding of a positive Double. grisu3 :: Double -> Maybe (ByteString, Int) instance Mason.Builder.Internal.Buildable Mason.Builder.Internal.SocketEnv instance Mason.Builder.Internal.Buildable Mason.Builder.Internal.PutBuilderEnv instance Mason.Builder.Internal.Buildable Mason.Builder.Internal.Channel instance Mason.Builder.Internal.Buildable Mason.Builder.Internal.GrowingBuffer instance Mason.Builder.Internal.Buildable () instance Mason.Builder.Internal.Buildable s => Data.String.IsString (Mason.Builder.Internal.BuilderFor s) instance GHC.Base.Semigroup (Mason.Builder.Internal.BuilderFor s) instance GHC.Base.Monoid (Mason.Builder.Internal.BuilderFor a) module Mason.Builder -- | The Builder type. Requires RankNTypes extension type Builder = forall s. Buildable s => BuilderFor s -- | Builder specialised for a backend data BuilderFor s -- | This class is used to provide backend-specific operations for running -- a Builder. class Buildable s -- | Create a strict ByteString toStrictByteString :: BuilderFor GrowingBuffer -> ByteString -- | Create a lazy ByteString. Threaded runtime is required. toLazyByteString :: BuilderFor Channel -> ByteString -- | 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. hPutBuilderLen :: Handle -> BuilderFor PutBuilderEnv -> IO Int -- | Put the content of a Builder to a Handle. hPutBuilder :: Handle -> BuilderFor PutBuilderEnv -> IO () -- | Write a Builder into a handle and obtain the number of bytes -- written. sendBuilder :: Socket -> BuilderFor SocketEnv -> IO Int -- | Flush the content of the internal buffer. flush :: Buildable s => BuilderFor s -- | Encode Text as a UTF-8 byte stream. encodeUtf8Builder :: Text -> Builder -- | Encode Text with a custom escaping function encodeUtf8BuilderEscaped :: BoundedPrim Word8 -> Text -> Builder -- | Put a ByteString. byteString :: Buildable s => ByteString -> BuilderFor s -- | Combine chunks of a lazy ByteString lazyByteString :: ByteString -> Builder -- | Copy a ShortByteString to a buffer. shortByteString :: ShortByteString -> Builder -- | Encode a single signed byte as-is. int8 :: Int8 -> Builder -- | Encode a single unsigned byte as-is. word8 :: Word8 -> Builder -- | Encode an Int16 in little endian format. int16LE :: Int16 -> Builder -- | Encode an Int32 in little endian format. int32LE :: Int32 -> Builder -- | Encode an Int64 in little endian format. int64LE :: Int64 -> Builder -- | Encode a Word16 in little endian format. word16LE :: Word16 -> Builder -- | Encode a Word32 in little endian format. word32LE :: Word32 -> Builder -- | Encode a Word64 in little endian format. word64LE :: Word64 -> Builder -- | Encode a Float in little endian format. floatLE :: Float -> Builder -- | Encode a Double in little endian format. doubleLE :: Double -> Builder -- | Encode an Int16 in big endian format. int16BE :: Int16 -> Builder -- | Encode an Int32 in big endian format. int32BE :: Int32 -> Builder -- | Encode an Int64 in big endian format. int64BE :: Int64 -> Builder -- | Encode a Word16 in big endian format. word16BE :: Word16 -> Builder -- | Encode a Word32 in big endian format. word32BE :: Word32 -> Builder -- | Encode a Word64 in big endian format. word64BE :: Word64 -> Builder -- | Encode a Float in big endian format. floatBE :: Float -> Builder -- | Encode a Double in big endian format. doubleBE :: Double -> Builder -- | Char7 encode a Char. char7 :: Char -> Builder -- | Char7 encode a String. string7 :: String -> Builder -- | Char8 encode a Char. char8 :: Char -> Builder -- | Char8 encode a String. string8 :: String -> Builder -- | UTF-8 encode a Char. charUtf8 :: Char -> Builder -- | UTF-8 encode a String. stringUtf8 :: String -> Builder -- | Currently slow. Decimal encoding of an IEEE Float. floatDec :: Float -> Builder -- | Decimal encoding of an IEEE Double. doubleDec :: Double -> Builder -- | Decimal encoding of a Word8 using the ASCII digits. word8Dec :: Word8 -> Builder -- | Decimal encoding of a Word16 using the ASCII digits. word16Dec :: Word16 -> Builder -- | Decimal encoding of a Word32 using the ASCII digits. word32Dec :: Word32 -> Builder -- | Decimal encoding of a Word64 using the ASCII digits. word64Dec :: Word64 -> Builder -- | Decimal encoding of a Word using the ASCII digits. wordDec :: Word -> Builder -- | Decimal encoding of an Int8 using the ASCII digits. -- -- e.g. -- --
-- toLazyByteString (int8Dec 42) = "42" -- toLazyByteString (int8Dec (-1)) = "-1" --int8Dec :: Int8 -> Builder -- | Decimal encoding of an Int16 using the ASCII digits. int16Dec :: Int16 -> Builder -- | Decimal encoding of an Int32 using the ASCII digits. int32Dec :: Int32 -> Builder -- | Decimal encoding of an Int64 using the ASCII digits. int64Dec :: Int64 -> Builder -- | Decimal encoding of an Int using the ASCII digits. intDec :: Int -> Builder -- | Decimal encoding of an Integer using the ASCII digits. Simon -- Meier's improved implementation from -- https://github.com/haskell/bytestring/commit/92f19a5d94761042b44a433d7331107611e4d717 integerDec :: Integer -> Builder -- | Shortest hexadecimal encoding of a Word8 using lower-case -- characters. word8Hex :: Word8 -> Builder -- | Shortest hexadecimal encoding of a Word16 using lower-case -- characters. word16Hex :: Word16 -> Builder -- | Shortest hexadecimal encoding of a Word32 using lower-case -- characters. word32Hex :: Word32 -> Builder -- | Shortest hexadecimal encoding of a Word64 using lower-case -- characters. word64Hex :: Word64 -> Builder -- | Shortest hexadecimal encoding of a Word using lower-case -- characters. wordHex :: Word -> Builder -- | Encode a Int8 using 2 nibbles (hexadecimal digits). int8HexFixed :: Int8 -> Builder -- | Encode a Int16 using 4 nibbles. int16HexFixed :: Int16 -> Builder -- | Encode a Int32 using 8 nibbles. int32HexFixed :: Int32 -> Builder -- | Encode a Int64 using 16 nibbles. int64HexFixed :: Int64 -> Builder -- | Encode a Word8 using 2 nibbles (hexadecimal digits). word8HexFixed :: Word8 -> Builder -- | Encode a Word16 using 4 nibbles. word16HexFixed :: Word16 -> Builder -- | Encode a Word32 using 8 nibbles. word32HexFixed :: Word32 -> Builder -- | Encode a Word64 using 16 nibbles. word64HexFixed :: Word64 -> Builder -- | Encode an IEEE Float using 8 nibbles. floatHexFixed :: Float -> Builder -- | Encode an IEEE Double using 16 nibbles. doubleHexFixed :: Double -> Builder -- | Encode each byte of a ByteString using its fixed-width hex -- encoding. byteStringHex :: ByteString -> Builder -- | Encode each byte of a lazy ByteString using its fixed-width hex -- encoding. lazyByteStringHex :: ByteString -> Builder -- | Use FixedPrim primFixed :: FixedPrim a -> a -> Builder -- | Use BoundedPrim primBounded :: BoundedPrim a -> a -> Builder -- | Run a builder within a buffer and prefix it by the length. lengthPrefixedWithin :: Int -> BoundedPrim Int -> BuilderFor () -> Builder