@@ -19,14 +19,18 @@ module Streamly.Internal.Data.Serialize.TH.Bottom
19 , mkFieldName
19 , mkFieldName
20 , isUnitType
20 , isUnitType
23 , serializeW8List
24 , serializeW8List
24 , litIntegral
25 , litIntegral
25 , matchConstructor
27 , matchConstructor
26 , openConstructor
28 , openConstructor
@@ -35,13 +39,17 @@ module Streamly.Internal.Data.Serialize.TH.Bottom
40−import Data.Char (ord)
46+import Data.Char (chr, ord)
41import Data.List (foldl')
47import Data.List (foldl')
42import Data.Word (Word16, Word32, Word64, Word8)
48import Data.Word (Word16, Word32, Word64, Word8)
43import Data.Bits (Bits, (.|.), shiftL, zeroBits, xor)
49import Data.Bits (Bits, (.|.), shiftL, zeroBits, xor)
44import Streamly.Internal.System.IO (unsafeInlineIO)
50import Streamly.Internal.System.IO (unsafeInlineIO)
51+import Streamly.Internal.Data.Unbox (Unbox)
52+import Data.Proxy (Proxy)
46import Language.Haskell.TH
54import Language.Haskell.TH
47import Streamly.Internal.Data.Serialize.Type
55import Streamly.Internal.Data.Serialize.Type
@@ -211,6 +219,9 @@ isUnitType _ = False
211int_w8 :: Int -> Word8
219int_w8 :: Int -> Word8
212int_w8 = fromIntegral
220int_w8 = fromIntegral
222+int_w32 :: Int -> Word32
223+int_w32 = fromIntegral
214w8_w16 :: Word8 -> Word16
225w8_w16 :: Word8 -> Word16
215w8_w16 = fromIntegral
226w8_w16 = fromIntegral
@@ -226,6 +237,9 @@ w32_int = fromIntegral
226c2w :: Char -> Word8
237c2w :: Char -> Word8
227c2w = fromIntegral . ord
238c2w = fromIntegral . ord
240+wListToString :: [Word8] -> String
241+wListToString = fmap (chr . fromIntegral)
229--------------------------------------------------------------------------------
243--------------------------------------------------------------------------------
230-- Bit manipulation
244-- Bit manipulation
231--------------------------------------------------------------------------------
245--------------------------------------------------------------------------------
@@ -349,3 +363,28 @@ serializeW8List off arr w8List = do
350litIntegral :: Integral a => a -> Q Exp
364litIntegral :: Integral a => a -> Q Exp
351litIntegral = litE . IntegerL . fromIntegral
365litIntegral = litE . IntegerL . fromIntegral
367+litProxy :: Unbox a => Proxy a -> Q Exp
368+litProxy = litE . IntegerL . fromIntegral . Unbox.sizeOf
370+--------------------------------------------------------------------------------
372+--------------------------------------------------------------------------------
374+errorUnsupported :: a
379+ , "There is improper use of the library."
380+ , "This case is unsupported."
381+ , "Please contact the developer if this case is of interest."
384+errorUnimplemented :: a
389+ , "Please contact the developer if this case is of interest."