{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeSynonymInstances #-}
module Data.Bytes.Builder.Class
( ToBuilder(..)
) where
import Data.Bytes (Bytes)
import Data.Bytes.Builder (Builder)
import Data.ByteString.Short (ShortByteString)
import Data.Int
import Data.Primitive.ByteArray (ByteArray)
import Data.Text.Short (ShortText)
import Data.Word
import qualified Data.Bytes.Builder as Builder
class ToBuilder a where
toBuilder :: a -> Builder
instance ToBuilder Builder where
toBuilder :: Builder -> Builder
toBuilder = Builder -> Builder
forall a. a -> a
id
instance ToBuilder Bytes where
toBuilder :: Bytes -> Builder
toBuilder = Bytes -> Builder
Builder.bytes
instance ToBuilder ByteArray where
toBuilder :: ByteArray -> Builder
toBuilder = ByteArray -> Builder
Builder.byteArray
instance ToBuilder ShortByteString where
toBuilder :: ShortByteString -> Builder
toBuilder = ShortByteString -> Builder
Builder.shortByteString
instance ToBuilder ShortText where
toBuilder :: ShortText -> Builder
toBuilder = ShortText -> Builder
Builder.shortTextUtf8
instance ToBuilder String where
toBuilder :: String -> Builder
toBuilder = String -> Builder
Builder.stringUtf8
instance ToBuilder Int64 where
toBuilder :: Int64 -> Builder
toBuilder = Int64 -> Builder
Builder.int64Dec
instance ToBuilder Int32 where
toBuilder :: Int32 -> Builder
toBuilder = Int32 -> Builder
Builder.int32Dec
instance ToBuilder Int16 where
toBuilder :: Int16 -> Builder
toBuilder = Int16 -> Builder
Builder.int16Dec
instance ToBuilder Int8 where
toBuilder :: Int8 -> Builder
toBuilder = Int8 -> Builder
Builder.int8Dec
instance ToBuilder Int where
toBuilder :: Int -> Builder
toBuilder = Int -> Builder
Builder.intDec
instance ToBuilder Word64 where
toBuilder :: Word64 -> Builder
toBuilder = Word64 -> Builder
Builder.word64Dec
instance ToBuilder Word32 where
toBuilder :: Word32 -> Builder
toBuilder = Word32 -> Builder
Builder.word32Dec
instance ToBuilder Word16 where
toBuilder :: Word16 -> Builder
toBuilder = Word16 -> Builder
Builder.word16Dec
instance ToBuilder Word8 where
toBuilder :: Word8 -> Builder
toBuilder = Word8 -> Builder
Builder.word8Dec
instance ToBuilder Word where
toBuilder :: Word -> Builder
toBuilder = Word -> Builder
Builder.wordDec
instance ToBuilder Double where
toBuilder :: Double -> Builder
toBuilder = Double -> Builder
Builder.doubleDec