{-# LANGUAGE CPP #-}
{-# LANGUAGE UnicodeSyntax #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Data.Deserializer
(
Deserializer(..)
, BinaryDeserializer(..)
, CerealDeserializer(..)
, word16H
, word32H
, word64H
, word
, wordL
, wordB
, wordH
, int8
, int16
, int16L
, int16B
, int16H
, int32
, int32L
, int32B
, int32H
, int64
, int64L
, int64B
, int64H
, int
, intL
, intB
, intH
, module Text.Parser.Combinators
, label
, module Text.Parser.LookAhead
, LittleEndianDeserializer(..)
, BigEndianDeserializer(..)
, deserializeIn
, deserializeH
, Deserialized(..)
, isDeserialized
, isMalformed
, maybeDeserialized
, defaultDeserializer
, Deserializable(..)
, getIn
, getL
, getB
, getH
, deserializeBytes
, deserializeBytesAs
, deserializeByteString
, deserializeByteStringAs
, deserializeLazyByteString
, deserializeLazyByteStringAs
, fromBytes
, fromBytesAs
, fromByteString
, fromByteStringAs
, fromLazyByteString
, fromLazyByteStringAs
, RestDeserializable(..)
) where
import Prelude hiding (take)
import GHC.Generics (Generic)
import Data.Typeable (Typeable)
import Data.Data (Data)
import Data.Proxy (Proxy(..))
import Data.Endian (Endian(..), swapEndian)
import Data.Word
import Data.Int
import Data.Bits ((.|.), shiftL)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Unsafe as BS
import qualified Data.ByteString.Short as SBS
import qualified Data.ByteString.Lazy as LBS
import qualified Data.ByteString.Builder as BB
import qualified Data.Binary.Get as B
import qualified Data.Binary.Get.Internal as B
import qualified Data.Serialize.Get as S
import Data.List.Split (splitOn)
import Text.Parser.Combinators
import Text.Parser.LookAhead
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative (Applicative(..), (<$>), (<$), (<*>), (*>))
#endif
import Control.Applicative (Alternative, (<|>))
import Control.Monad (unless)
class (Monad μ, Parsing μ) ⇒ Deserializer μ where
{-# MINIMAL ensure, take, chunk, isolate #-}
endian ∷ Proxy μ → Endian
#ifdef WORDS_BIGENDIAN
endian _ = BigEndian
#else
endian Proxy μ
_ = Endian
LittleEndian
#endif
word8 ∷ μ Word8
word8 = ByteString -> Word8
BS.unsafeHead (ByteString -> Word8) -> μ ByteString -> μ Word8
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> μ ByteString
forall (μ :: * -> *). Deserializer μ => Int -> μ ByteString
take Int
1 μ Word8 -> String -> μ Word8
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"word8"
{-# INLINE word8 #-}
word16 ∷ μ Word16
word16 = Endian -> μ Word16
forall (μ :: * -> *) α.
(Deserializer μ, Deserializable α) =>
Endian -> μ α
getIn (Proxy μ -> Endian
forall (μ :: * -> *). Deserializer μ => Proxy μ -> Endian
endian (Proxy μ
forall k (t :: k). Proxy t
Proxy ∷ Proxy μ))
{-# INLINE word16 #-}
word32 ∷ μ Word32
word32 = Endian -> μ Word32
forall (μ :: * -> *) α.
(Deserializer μ, Deserializable α) =>
Endian -> μ α
getIn (Proxy μ -> Endian
forall (μ :: * -> *). Deserializer μ => Proxy μ -> Endian
endian (Proxy μ
forall k (t :: k). Proxy t
Proxy ∷ Proxy μ))
{-# INLINE word32 #-}
word64 ∷ μ Word64
word64 = Endian -> μ Word64
forall (μ :: * -> *) α.
(Deserializer μ, Deserializable α) =>
Endian -> μ α
getIn (Proxy μ -> Endian
forall (μ :: * -> *). Deserializer μ => Proxy μ -> Endian
endian (Proxy μ
forall k (t :: k). Proxy t
Proxy ∷ Proxy μ))
{-# INLINE word64 #-}
word16L ∷ μ Word16
word16L = (μ Word16 -> String -> μ Word16
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"word16")
(μ Word16 -> μ Word16) -> μ Word16 -> μ Word16
forall a b. (a -> b) -> a -> b
$ do ByteString
bs ← Int -> μ ByteString
forall (μ :: * -> *). Deserializer μ => Int -> μ ByteString
take Int
2
let l :: Word8
l = ByteString -> Int -> Word8
BS.unsafeIndex ByteString
bs Int
0
h :: Word8
h = ByteString -> Int -> Word8
BS.unsafeIndex ByteString
bs Int
1
Word16 -> μ Word16
forall (m :: * -> *) a. Monad m => a -> m a
return (Word16 -> μ Word16) -> Word16 -> μ Word16
forall a b. (a -> b) -> a -> b
$ Word16 -> Int -> Word16
forall a. Bits a => a -> Int -> a
shiftL (Word8 -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
h) Int
8 Word16 -> Word16 -> Word16
forall a. Bits a => a -> a -> a
.|. Word8 -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
l
word16B ∷ μ Word16
word16B = Word16 -> Word16
forall α. EndianSensitive α => α -> α
swapEndian (Word16 -> Word16) -> μ Word16 -> μ Word16
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word16
forall (μ :: * -> *). Deserializer μ => μ Word16
word16L
word32L ∷ μ Word32
word32L = (μ Word32 -> String -> μ Word32
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"word32")
(μ Word32 -> μ Word32) -> μ Word32 -> μ Word32
forall a b. (a -> b) -> a -> b
$ do ByteString
bs ← Int -> μ ByteString
forall (μ :: * -> *). Deserializer μ => Int -> μ ByteString
take Int
4
let o₀ :: Word8
o₀ = ByteString -> Int -> Word8
BS.unsafeIndex ByteString
bs Int
0
o₁ :: Word8
o₁ = ByteString -> Int -> Word8
BS.unsafeIndex ByteString
bs Int
1
o₂ :: Word8
o₂ = ByteString -> Int -> Word8
BS.unsafeIndex ByteString
bs Int
2
o₃ :: Word8
o₃ = ByteString -> Int -> Word8
BS.unsafeIndex ByteString
bs Int
3
Word32 -> μ Word32
forall (m :: * -> *) a. Monad m => a -> m a
return (Word32 -> μ Word32) -> Word32 -> μ Word32
forall a b. (a -> b) -> a -> b
$ Word32 -> Int -> Word32
forall a. Bits a => a -> Int -> a
shiftL (Word8 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
o₃) Int
24
Word32 -> Word32 -> Word32
forall a. Bits a => a -> a -> a
.|. Word32 -> Int -> Word32
forall a. Bits a => a -> Int -> a
shiftL (Word8 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
o₂) Int
16
Word32 -> Word32 -> Word32
forall a. Bits a => a -> a -> a
.|. Word32 -> Int -> Word32
forall a. Bits a => a -> Int -> a
shiftL (Word8 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
o₁) Int
8
Word32 -> Word32 -> Word32
forall a. Bits a => a -> a -> a
.|. Word8 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
o₀
word32B ∷ μ Word32
word32B = Word32 -> Word32
forall α. EndianSensitive α => α -> α
swapEndian (Word32 -> Word32) -> μ Word32 -> μ Word32
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word32
forall (μ :: * -> *). Deserializer μ => μ Word32
word32L
word64L ∷ μ Word64
word64L = (μ Word64 -> String -> μ Word64
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"word64")
(μ Word64 -> μ Word64) -> μ Word64 -> μ Word64
forall a b. (a -> b) -> a -> b
$ do ByteString
bs ← Int -> μ ByteString
forall (μ :: * -> *). Deserializer μ => Int -> μ ByteString
take Int
8
let o₀ :: Word8
o₀ = ByteString -> Int -> Word8
BS.unsafeIndex ByteString
bs Int
0
o₁ :: Word8
o₁ = ByteString -> Int -> Word8
BS.unsafeIndex ByteString
bs Int
1
o₂ :: Word8
o₂ = ByteString -> Int -> Word8
BS.unsafeIndex ByteString
bs Int
2
o₃ :: Word8
o₃ = ByteString -> Int -> Word8
BS.unsafeIndex ByteString
bs Int
3
o₄ :: Word8
o₄ = ByteString -> Int -> Word8
BS.unsafeIndex ByteString
bs Int
4
o₅ :: Word8
o₅ = ByteString -> Int -> Word8
BS.unsafeIndex ByteString
bs Int
5
o₆ :: Word8
o₆ = ByteString -> Int -> Word8
BS.unsafeIndex ByteString
bs Int
6
o₇ :: Word8
o₇ = ByteString -> Int -> Word8
BS.unsafeIndex ByteString
bs Int
7
Word64 -> μ Word64
forall (m :: * -> *) a. Monad m => a -> m a
return (Word64 -> μ Word64) -> Word64 -> μ Word64
forall a b. (a -> b) -> a -> b
$ Word64 -> Int -> Word64
forall a. Bits a => a -> Int -> a
shiftL (Word8 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
o₇) Int
56
Word64 -> Word64 -> Word64
forall a. Bits a => a -> a -> a
.|. Word64 -> Int -> Word64
forall a. Bits a => a -> Int -> a
shiftL (Word8 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
o₆) Int
48
Word64 -> Word64 -> Word64
forall a. Bits a => a -> a -> a
.|. Word64 -> Int -> Word64
forall a. Bits a => a -> Int -> a
shiftL (Word8 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
o₅) Int
40
Word64 -> Word64 -> Word64
forall a. Bits a => a -> a -> a
.|. Word64 -> Int -> Word64
forall a. Bits a => a -> Int -> a
shiftL (Word8 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
o₄) Int
32
Word64 -> Word64 -> Word64
forall a. Bits a => a -> a -> a
.|. Word64 -> Int -> Word64
forall a. Bits a => a -> Int -> a
shiftL (Word8 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
o₃) Int
24
Word64 -> Word64 -> Word64
forall a. Bits a => a -> a -> a
.|. Word64 -> Int -> Word64
forall a. Bits a => a -> Int -> a
shiftL (Word8 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
o₂) Int
16
Word64 -> Word64 -> Word64
forall a. Bits a => a -> a -> a
.|. Word64 -> Int -> Word64
forall a. Bits a => a -> Int -> a
shiftL (Word8 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
o₁) Int
8
Word64 -> Word64 -> Word64
forall a. Bits a => a -> a -> a
.|. Word8 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
o₀
word64B ∷ μ Word64
word64B = Word64 -> Word64
forall α. EndianSensitive α => α -> α
swapEndian (Word64 -> Word64) -> μ Word64 -> μ Word64
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word64
forall (μ :: * -> *). Deserializer μ => μ Word64
word64L
satisfy ∷ (Word8 → Bool) → μ Word8
satisfy Word8 -> Bool
p = do Word8
w ← μ Word8
forall (μ :: * -> *). Deserializer μ => μ Word8
word8
if Word8 -> Bool
p Word8
w then Word8 -> μ Word8
forall (m :: * -> *) a. Monad m => a -> m a
return Word8
w
else String -> μ Word8
forall (m :: * -> *) a. Parsing m => String -> m a
unexpected (Word8 -> String
forall a. Show a => a -> String
show Word8
w)
{-# INLINE satisfy #-}
byte ∷ Word8 → μ Word8
byte Word8
w = (μ Word8 -> String -> μ Word8
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"byte " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Word8 -> String
forall a. Show a => a -> String
show Word8
w)
(μ Word8 -> μ Word8) -> μ Word8 -> μ Word8
forall a b. (a -> b) -> a -> b
$ do Word8
w' ← μ Word8
forall (μ :: * -> *). Deserializer μ => μ Word8
word8
if Word8
w' Word8 -> Word8 -> Bool
forall a. Eq a => a -> a -> Bool
== Word8
w then Word8 -> μ Word8
forall (m :: * -> *) a. Monad m => a -> m a
return Word8
w'
else String -> μ Word8
forall (m :: * -> *) a. Parsing m => String -> m a
unexpected (Word8 -> String
forall a. Show a => a -> String
show Word8
w')
{-# INLINE byte #-}
notByte ∷ Word8 → μ Word8
notByte Word8
w = (μ Word8 -> String -> μ Word8
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"not byte " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Word8 -> String
forall a. Show a => a -> String
show Word8
w)
(μ Word8 -> μ Word8) -> μ Word8 -> μ Word8
forall a b. (a -> b) -> a -> b
$ do Word8
w' ← μ Word8
forall (μ :: * -> *). Deserializer μ => μ Word8
word8
if Word8
w' Word8 -> Word8 -> Bool
forall a. Eq a => a -> a -> Bool
== Word8
w then String -> μ Word8
forall (m :: * -> *) a. Parsing m => String -> m a
unexpected (Word8 -> String
forall a. Show a => a -> String
show Word8
w')
else Word8 -> μ Word8
forall (m :: * -> *) a. Monad m => a -> m a
return Word8
w'
{-# INLINE notByte #-}
bytes ∷ BS.ByteString → μ BS.ByteString
bytes ByteString
bs = (μ ByteString -> String -> μ ByteString
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"bytes " String -> String -> String
forall a. [a] -> [a] -> [a]
++ [Word8] -> String
forall a. Show a => a -> String
show (ByteString -> [Word8]
BS.unpack ByteString
bs))
(μ ByteString -> μ ByteString) -> μ ByteString -> μ ByteString
forall a b. (a -> b) -> a -> b
$ do ByteString
bs' ← Int -> μ ByteString
forall (μ :: * -> *). Deserializer μ => Int -> μ ByteString
take (ByteString -> Int
BS.length ByteString
bs)
if ByteString
bs' ByteString -> ByteString -> Bool
forall a. Eq a => a -> a -> Bool
== ByteString
bs then ByteString -> μ ByteString
forall (m :: * -> *) a. Monad m => a -> m a
return ByteString
bs'
else String -> μ ByteString
forall (m :: * -> *) a. Parsing m => String -> m a
unexpected ([Word8] -> String
forall a. Show a => a -> String
show ([Word8] -> String) -> [Word8] -> String
forall a b. (a -> b) -> a -> b
$ ByteString -> [Word8]
BS.unpack ByteString
bs')
{-# INLINE bytes #-}
skip ∷ Int → μ ()
skip Int
n | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = () -> μ ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
| Bool
otherwise = μ Word8
forall (μ :: * -> *). Deserializer μ => μ Word8
word8 μ Word8 -> μ () -> μ ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> μ ()
forall (μ :: * -> *). Deserializer μ => Int -> μ ()
skip (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)
ensure ∷ Int → μ BS.ByteString
ensure_ ∷ Int → μ ()
ensure_ = (() () -> μ ByteString -> μ ()
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$) (μ ByteString -> μ ()) -> (Int -> μ ByteString) -> Int -> μ ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> μ ByteString
forall (μ :: * -> *). Deserializer μ => Int -> μ ByteString
ensure
{-# INLINE ensure_ #-}
check ∷ Int → μ Bool
check Int
n = Bool
True Bool -> μ () -> μ Bool
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Int -> μ ()
forall (μ :: * -> *). Deserializer μ => Int -> μ ()
ensure_ Int
n μ Bool -> μ Bool -> μ Bool
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Bool -> μ Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
{-# INLINE check #-}
take ∷ Int → μ BS.ByteString
chunk ∷ μ BS.ByteString
isolate ∷ Int → μ α → μ α
newtype BinaryDeserializer α =
BinaryDeserializer { BinaryDeserializer α -> Get α
binaryDeserializer ∷ B.Get α }
deriving (Typeable, (forall x. BinaryDeserializer α -> Rep (BinaryDeserializer α) x)
-> (forall x. Rep (BinaryDeserializer α) x -> BinaryDeserializer α)
-> Generic (BinaryDeserializer α)
forall x. Rep (BinaryDeserializer α) x -> BinaryDeserializer α
forall x. BinaryDeserializer α -> Rep (BinaryDeserializer α) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall α x. Rep (BinaryDeserializer α) x -> BinaryDeserializer α
forall α x. BinaryDeserializer α -> Rep (BinaryDeserializer α) x
$cto :: forall α x. Rep (BinaryDeserializer α) x -> BinaryDeserializer α
$cfrom :: forall α x. BinaryDeserializer α -> Rep (BinaryDeserializer α) x
Generic, a -> BinaryDeserializer b -> BinaryDeserializer a
(a -> b) -> BinaryDeserializer a -> BinaryDeserializer b
(forall a b.
(a -> b) -> BinaryDeserializer a -> BinaryDeserializer b)
-> (forall a b. a -> BinaryDeserializer b -> BinaryDeserializer a)
-> Functor BinaryDeserializer
forall a b. a -> BinaryDeserializer b -> BinaryDeserializer a
forall a b.
(a -> b) -> BinaryDeserializer a -> BinaryDeserializer b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> BinaryDeserializer b -> BinaryDeserializer a
$c<$ :: forall a b. a -> BinaryDeserializer b -> BinaryDeserializer a
fmap :: (a -> b) -> BinaryDeserializer a -> BinaryDeserializer b
$cfmap :: forall a b.
(a -> b) -> BinaryDeserializer a -> BinaryDeserializer b
Functor, Functor BinaryDeserializer
a -> BinaryDeserializer a
Functor BinaryDeserializer
-> (forall a. a -> BinaryDeserializer a)
-> (forall a b.
BinaryDeserializer (a -> b)
-> BinaryDeserializer a -> BinaryDeserializer b)
-> (forall a b c.
(a -> b -> c)
-> BinaryDeserializer a
-> BinaryDeserializer b
-> BinaryDeserializer c)
-> (forall a b.
BinaryDeserializer a
-> BinaryDeserializer b -> BinaryDeserializer b)
-> (forall a b.
BinaryDeserializer a
-> BinaryDeserializer b -> BinaryDeserializer a)
-> Applicative BinaryDeserializer
BinaryDeserializer a
-> BinaryDeserializer b -> BinaryDeserializer b
BinaryDeserializer a
-> BinaryDeserializer b -> BinaryDeserializer a
BinaryDeserializer (a -> b)
-> BinaryDeserializer a -> BinaryDeserializer b
(a -> b -> c)
-> BinaryDeserializer a
-> BinaryDeserializer b
-> BinaryDeserializer c
forall a. a -> BinaryDeserializer a
forall a b.
BinaryDeserializer a
-> BinaryDeserializer b -> BinaryDeserializer a
forall a b.
BinaryDeserializer a
-> BinaryDeserializer b -> BinaryDeserializer b
forall a b.
BinaryDeserializer (a -> b)
-> BinaryDeserializer a -> BinaryDeserializer b
forall a b c.
(a -> b -> c)
-> BinaryDeserializer a
-> BinaryDeserializer b
-> BinaryDeserializer c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: BinaryDeserializer a
-> BinaryDeserializer b -> BinaryDeserializer a
$c<* :: forall a b.
BinaryDeserializer a
-> BinaryDeserializer b -> BinaryDeserializer a
*> :: BinaryDeserializer a
-> BinaryDeserializer b -> BinaryDeserializer b
$c*> :: forall a b.
BinaryDeserializer a
-> BinaryDeserializer b -> BinaryDeserializer b
liftA2 :: (a -> b -> c)
-> BinaryDeserializer a
-> BinaryDeserializer b
-> BinaryDeserializer c
$cliftA2 :: forall a b c.
(a -> b -> c)
-> BinaryDeserializer a
-> BinaryDeserializer b
-> BinaryDeserializer c
<*> :: BinaryDeserializer (a -> b)
-> BinaryDeserializer a -> BinaryDeserializer b
$c<*> :: forall a b.
BinaryDeserializer (a -> b)
-> BinaryDeserializer a -> BinaryDeserializer b
pure :: a -> BinaryDeserializer a
$cpure :: forall a. a -> BinaryDeserializer a
$cp1Applicative :: Functor BinaryDeserializer
Applicative,
Applicative BinaryDeserializer
BinaryDeserializer a
Applicative BinaryDeserializer
-> (forall a. BinaryDeserializer a)
-> (forall a.
BinaryDeserializer a
-> BinaryDeserializer a -> BinaryDeserializer a)
-> (forall a. BinaryDeserializer a -> BinaryDeserializer [a])
-> (forall a. BinaryDeserializer a -> BinaryDeserializer [a])
-> Alternative BinaryDeserializer
BinaryDeserializer a
-> BinaryDeserializer a -> BinaryDeserializer a
BinaryDeserializer a -> BinaryDeserializer [a]
BinaryDeserializer a -> BinaryDeserializer [a]
forall a. BinaryDeserializer a
forall a. BinaryDeserializer a -> BinaryDeserializer [a]
forall a.
BinaryDeserializer a
-> BinaryDeserializer a -> BinaryDeserializer a
forall (f :: * -> *).
Applicative f
-> (forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
many :: BinaryDeserializer a -> BinaryDeserializer [a]
$cmany :: forall a. BinaryDeserializer a -> BinaryDeserializer [a]
some :: BinaryDeserializer a -> BinaryDeserializer [a]
$csome :: forall a. BinaryDeserializer a -> BinaryDeserializer [a]
<|> :: BinaryDeserializer a
-> BinaryDeserializer a -> BinaryDeserializer a
$c<|> :: forall a.
BinaryDeserializer a
-> BinaryDeserializer a -> BinaryDeserializer a
empty :: BinaryDeserializer a
$cempty :: forall a. BinaryDeserializer a
$cp1Alternative :: Applicative BinaryDeserializer
Alternative, Applicative BinaryDeserializer
a -> BinaryDeserializer a
Applicative BinaryDeserializer
-> (forall a b.
BinaryDeserializer a
-> (a -> BinaryDeserializer b) -> BinaryDeserializer b)
-> (forall a b.
BinaryDeserializer a
-> BinaryDeserializer b -> BinaryDeserializer b)
-> (forall a. a -> BinaryDeserializer a)
-> Monad BinaryDeserializer
BinaryDeserializer a
-> (a -> BinaryDeserializer b) -> BinaryDeserializer b
BinaryDeserializer a
-> BinaryDeserializer b -> BinaryDeserializer b
forall a. a -> BinaryDeserializer a
forall a b.
BinaryDeserializer a
-> BinaryDeserializer b -> BinaryDeserializer b
forall a b.
BinaryDeserializer a
-> (a -> BinaryDeserializer b) -> BinaryDeserializer b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> BinaryDeserializer a
$creturn :: forall a. a -> BinaryDeserializer a
>> :: BinaryDeserializer a
-> BinaryDeserializer b -> BinaryDeserializer b
$c>> :: forall a b.
BinaryDeserializer a
-> BinaryDeserializer b -> BinaryDeserializer b
>>= :: BinaryDeserializer a
-> (a -> BinaryDeserializer b) -> BinaryDeserializer b
$c>>= :: forall a b.
BinaryDeserializer a
-> (a -> BinaryDeserializer b) -> BinaryDeserializer b
$cp1Monad :: Applicative BinaryDeserializer
Monad)
instance Parsing BinaryDeserializer where
try :: BinaryDeserializer a -> BinaryDeserializer a
try BinaryDeserializer a
p = BinaryDeserializer a
p
{-# INLINE try #-}
BinaryDeserializer a
p <?> :: BinaryDeserializer a -> String -> BinaryDeserializer a
<?> String
l = Get a -> BinaryDeserializer a
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer (String -> Get a -> Get a
forall a. String -> Get a -> Get a
B.label String
l (BinaryDeserializer a -> Get a
forall α. BinaryDeserializer α -> Get α
binaryDeserializer BinaryDeserializer a
p))
{-# INLINE (<?>) #-}
skipMany :: BinaryDeserializer a -> BinaryDeserializer ()
skipMany BinaryDeserializer a
p = ((Bool
True Bool -> BinaryDeserializer a -> BinaryDeserializer Bool
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ BinaryDeserializer a
p) BinaryDeserializer Bool
-> BinaryDeserializer Bool -> BinaryDeserializer Bool
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Bool -> BinaryDeserializer Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
False) BinaryDeserializer Bool
-> (Bool -> BinaryDeserializer ()) -> BinaryDeserializer ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Bool
True → BinaryDeserializer a -> BinaryDeserializer ()
forall (m :: * -> *) a. Parsing m => m a -> m ()
skipMany BinaryDeserializer a
p
Bool
False → () -> BinaryDeserializer ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
unexpected :: String -> BinaryDeserializer a
unexpected = Get a -> BinaryDeserializer a
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer (Get a -> BinaryDeserializer a)
-> (String -> Get a) -> String -> BinaryDeserializer a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Get a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail
{-# INLINE unexpected #-}
eof :: BinaryDeserializer ()
eof = Get () -> BinaryDeserializer ()
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer
(Get () -> BinaryDeserializer ())
-> Get () -> BinaryDeserializer ()
forall a b. (a -> b) -> a -> b
$ Get Bool
B.isEmpty Get Bool -> (Bool -> Get ()) -> Get ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Bool
True → () -> Get ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Bool
False → String -> Get ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Parsing.eof"
{-# INLINABLE eof #-}
notFollowedBy :: BinaryDeserializer a -> BinaryDeserializer ()
notFollowedBy BinaryDeserializer a
p = Get () -> BinaryDeserializer ()
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer
(Get () -> BinaryDeserializer ())
-> Get () -> BinaryDeserializer ()
forall a b. (a -> b) -> a -> b
$ (Get (Either a ()) -> Get (Either a ())
forall a b. Get (Either a b) -> Get (Either a b)
B.lookAheadE (a -> Either a ()
forall a b. a -> Either a b
Left (a -> Either a ()) -> Get a -> Get (Either a ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (BinaryDeserializer a -> Get a
forall α. BinaryDeserializer α -> Get α
binaryDeserializer BinaryDeserializer a
p)) Get (Either a ()) -> Get (Either a ()) -> Get (Either a ())
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
Either a () -> Get (Either a ())
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> Either a ()
forall a b. b -> Either a b
Right ())) Get (Either a ()) -> (Either a () -> Get ()) -> Get ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Left a
e → String -> Get ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (a -> String
forall a. Show a => a -> String
show a
e)
Right ()
_ → () -> Get ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
{-# INLINABLE notFollowedBy #-}
instance LookAheadParsing BinaryDeserializer where
lookAhead :: BinaryDeserializer a -> BinaryDeserializer a
lookAhead = Get a -> BinaryDeserializer a
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer (Get a -> BinaryDeserializer a)
-> (BinaryDeserializer a -> Get a)
-> BinaryDeserializer a
-> BinaryDeserializer a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Get a -> Get a
forall a. Get a -> Get a
B.lookAhead (Get a -> Get a)
-> (BinaryDeserializer a -> Get a) -> BinaryDeserializer a -> Get a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BinaryDeserializer a -> Get a
forall α. BinaryDeserializer α -> Get α
binaryDeserializer
{-# INLINE lookAhead #-}
instance Deserializer BinaryDeserializer where
word8 :: BinaryDeserializer Word8
word8 = Get Word8 -> BinaryDeserializer Word8
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer Get Word8
B.getWord8
{-# INLINE word8 #-}
word16L :: BinaryDeserializer Word16
word16L = Get Word16 -> BinaryDeserializer Word16
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer Get Word16
B.getWord16le
{-# INLINE word16L #-}
word16B :: BinaryDeserializer Word16
word16B = Get Word16 -> BinaryDeserializer Word16
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer Get Word16
B.getWord16be
{-# INLINE word16B #-}
word32L :: BinaryDeserializer Word32
word32L = Get Word32 -> BinaryDeserializer Word32
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer Get Word32
B.getWord32le
{-# INLINE word32L #-}
word32B :: BinaryDeserializer Word32
word32B = Get Word32 -> BinaryDeserializer Word32
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer Get Word32
B.getWord32be
{-# INLINE word32B #-}
word64L :: BinaryDeserializer Word64
word64L = Get Word64 -> BinaryDeserializer Word64
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer Get Word64
B.getWord64le
{-# INLINE word64L #-}
word64B :: BinaryDeserializer Word64
word64B = Get Word64 -> BinaryDeserializer Word64
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer Get Word64
B.getWord64be
{-# INLINE word64B #-}
skip :: Int -> BinaryDeserializer ()
skip = Get () -> BinaryDeserializer ()
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer (Get () -> BinaryDeserializer ())
-> (Int -> Get ()) -> Int -> BinaryDeserializer ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Get ()
B.skip
{-# INLINE skip #-}
ensure :: Int -> BinaryDeserializer ByteString
ensure Int
n = Get ByteString -> BinaryDeserializer ByteString
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer (Int -> Get ()
B.ensureN Int
n Get () -> Get ByteString -> Get ByteString
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ByteString
B.get)
{-# INLINE ensure #-}
ensure_ :: Int -> BinaryDeserializer ()
ensure_ = Get () -> BinaryDeserializer ()
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer (Get () -> BinaryDeserializer ())
-> (Int -> Get ()) -> Int -> BinaryDeserializer ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Get ()
B.ensureN
{-# INLINE ensure_ #-}
take :: Int -> BinaryDeserializer ByteString
take = Get ByteString -> BinaryDeserializer ByteString
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer (Get ByteString -> BinaryDeserializer ByteString)
-> (Int -> Get ByteString) -> Int -> BinaryDeserializer ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Get ByteString
B.getByteString
{-# INLINE take #-}
chunk :: BinaryDeserializer ByteString
chunk = Get ByteString -> BinaryDeserializer ByteString
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer
(Get ByteString -> BinaryDeserializer ByteString)
-> Get ByteString -> BinaryDeserializer ByteString
forall a b. (a -> b) -> a -> b
$ do ByteString
bs ← Get ByteString
B.get
if ByteString -> Bool
BS.null ByteString
bs
then do
Bool
e ← Get Bool
B.isEmpty
if Bool
e
then ByteString -> Get ByteString
forall (m :: * -> *) a. Monad m => a -> m a
return ByteString
bs
else Get ByteString
B.get
else
ByteString -> Get ByteString
forall (m :: * -> *) a. Monad m => a -> m a
return ByteString
bs
{-# INLINABLE chunk #-}
isolate :: Int -> BinaryDeserializer α -> BinaryDeserializer α
isolate Int
n BinaryDeserializer α
d = Get α -> BinaryDeserializer α
forall α. Get α -> BinaryDeserializer α
BinaryDeserializer (Get α -> BinaryDeserializer α) -> Get α -> BinaryDeserializer α
forall a b. (a -> b) -> a -> b
$ Int -> Get α -> Get α
forall a. Int -> Get a -> Get a
B.isolate Int
n (BinaryDeserializer α -> Get α
forall α. BinaryDeserializer α -> Get α
binaryDeserializer BinaryDeserializer α
d)
{-# INLINE isolate #-}
newtype CerealDeserializer α =
CerealDeserializer { CerealDeserializer α -> Get α
cerealDeserializer ∷ S.Get α }
deriving (Typeable, (forall x. CerealDeserializer α -> Rep (CerealDeserializer α) x)
-> (forall x. Rep (CerealDeserializer α) x -> CerealDeserializer α)
-> Generic (CerealDeserializer α)
forall x. Rep (CerealDeserializer α) x -> CerealDeserializer α
forall x. CerealDeserializer α -> Rep (CerealDeserializer α) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall α x. Rep (CerealDeserializer α) x -> CerealDeserializer α
forall α x. CerealDeserializer α -> Rep (CerealDeserializer α) x
$cto :: forall α x. Rep (CerealDeserializer α) x -> CerealDeserializer α
$cfrom :: forall α x. CerealDeserializer α -> Rep (CerealDeserializer α) x
Generic, a -> CerealDeserializer b -> CerealDeserializer a
(a -> b) -> CerealDeserializer a -> CerealDeserializer b
(forall a b.
(a -> b) -> CerealDeserializer a -> CerealDeserializer b)
-> (forall a b. a -> CerealDeserializer b -> CerealDeserializer a)
-> Functor CerealDeserializer
forall a b. a -> CerealDeserializer b -> CerealDeserializer a
forall a b.
(a -> b) -> CerealDeserializer a -> CerealDeserializer b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> CerealDeserializer b -> CerealDeserializer a
$c<$ :: forall a b. a -> CerealDeserializer b -> CerealDeserializer a
fmap :: (a -> b) -> CerealDeserializer a -> CerealDeserializer b
$cfmap :: forall a b.
(a -> b) -> CerealDeserializer a -> CerealDeserializer b
Functor, Functor CerealDeserializer
a -> CerealDeserializer a
Functor CerealDeserializer
-> (forall a. a -> CerealDeserializer a)
-> (forall a b.
CerealDeserializer (a -> b)
-> CerealDeserializer a -> CerealDeserializer b)
-> (forall a b c.
(a -> b -> c)
-> CerealDeserializer a
-> CerealDeserializer b
-> CerealDeserializer c)
-> (forall a b.
CerealDeserializer a
-> CerealDeserializer b -> CerealDeserializer b)
-> (forall a b.
CerealDeserializer a
-> CerealDeserializer b -> CerealDeserializer a)
-> Applicative CerealDeserializer
CerealDeserializer a
-> CerealDeserializer b -> CerealDeserializer b
CerealDeserializer a
-> CerealDeserializer b -> CerealDeserializer a
CerealDeserializer (a -> b)
-> CerealDeserializer a -> CerealDeserializer b
(a -> b -> c)
-> CerealDeserializer a
-> CerealDeserializer b
-> CerealDeserializer c
forall a. a -> CerealDeserializer a
forall a b.
CerealDeserializer a
-> CerealDeserializer b -> CerealDeserializer a
forall a b.
CerealDeserializer a
-> CerealDeserializer b -> CerealDeserializer b
forall a b.
CerealDeserializer (a -> b)
-> CerealDeserializer a -> CerealDeserializer b
forall a b c.
(a -> b -> c)
-> CerealDeserializer a
-> CerealDeserializer b
-> CerealDeserializer c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: CerealDeserializer a
-> CerealDeserializer b -> CerealDeserializer a
$c<* :: forall a b.
CerealDeserializer a
-> CerealDeserializer b -> CerealDeserializer a
*> :: CerealDeserializer a
-> CerealDeserializer b -> CerealDeserializer b
$c*> :: forall a b.
CerealDeserializer a
-> CerealDeserializer b -> CerealDeserializer b
liftA2 :: (a -> b -> c)
-> CerealDeserializer a
-> CerealDeserializer b
-> CerealDeserializer c
$cliftA2 :: forall a b c.
(a -> b -> c)
-> CerealDeserializer a
-> CerealDeserializer b
-> CerealDeserializer c
<*> :: CerealDeserializer (a -> b)
-> CerealDeserializer a -> CerealDeserializer b
$c<*> :: forall a b.
CerealDeserializer (a -> b)
-> CerealDeserializer a -> CerealDeserializer b
pure :: a -> CerealDeserializer a
$cpure :: forall a. a -> CerealDeserializer a
$cp1Applicative :: Functor CerealDeserializer
Applicative,
Applicative CerealDeserializer
CerealDeserializer a
Applicative CerealDeserializer
-> (forall a. CerealDeserializer a)
-> (forall a.
CerealDeserializer a
-> CerealDeserializer a -> CerealDeserializer a)
-> (forall a. CerealDeserializer a -> CerealDeserializer [a])
-> (forall a. CerealDeserializer a -> CerealDeserializer [a])
-> Alternative CerealDeserializer
CerealDeserializer a
-> CerealDeserializer a -> CerealDeserializer a
CerealDeserializer a -> CerealDeserializer [a]
CerealDeserializer a -> CerealDeserializer [a]
forall a. CerealDeserializer a
forall a. CerealDeserializer a -> CerealDeserializer [a]
forall a.
CerealDeserializer a
-> CerealDeserializer a -> CerealDeserializer a
forall (f :: * -> *).
Applicative f
-> (forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
many :: CerealDeserializer a -> CerealDeserializer [a]
$cmany :: forall a. CerealDeserializer a -> CerealDeserializer [a]
some :: CerealDeserializer a -> CerealDeserializer [a]
$csome :: forall a. CerealDeserializer a -> CerealDeserializer [a]
<|> :: CerealDeserializer a
-> CerealDeserializer a -> CerealDeserializer a
$c<|> :: forall a.
CerealDeserializer a
-> CerealDeserializer a -> CerealDeserializer a
empty :: CerealDeserializer a
$cempty :: forall a. CerealDeserializer a
$cp1Alternative :: Applicative CerealDeserializer
Alternative, Applicative CerealDeserializer
a -> CerealDeserializer a
Applicative CerealDeserializer
-> (forall a b.
CerealDeserializer a
-> (a -> CerealDeserializer b) -> CerealDeserializer b)
-> (forall a b.
CerealDeserializer a
-> CerealDeserializer b -> CerealDeserializer b)
-> (forall a. a -> CerealDeserializer a)
-> Monad CerealDeserializer
CerealDeserializer a
-> (a -> CerealDeserializer b) -> CerealDeserializer b
CerealDeserializer a
-> CerealDeserializer b -> CerealDeserializer b
forall a. a -> CerealDeserializer a
forall a b.
CerealDeserializer a
-> CerealDeserializer b -> CerealDeserializer b
forall a b.
CerealDeserializer a
-> (a -> CerealDeserializer b) -> CerealDeserializer b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> CerealDeserializer a
$creturn :: forall a. a -> CerealDeserializer a
>> :: CerealDeserializer a
-> CerealDeserializer b -> CerealDeserializer b
$c>> :: forall a b.
CerealDeserializer a
-> CerealDeserializer b -> CerealDeserializer b
>>= :: CerealDeserializer a
-> (a -> CerealDeserializer b) -> CerealDeserializer b
$c>>= :: forall a b.
CerealDeserializer a
-> (a -> CerealDeserializer b) -> CerealDeserializer b
$cp1Monad :: Applicative CerealDeserializer
Monad)
instance Parsing CerealDeserializer where
try :: CerealDeserializer a -> CerealDeserializer a
try CerealDeserializer a
p = CerealDeserializer a
p
{-# INLINE try #-}
CerealDeserializer a
p <?> :: CerealDeserializer a -> String -> CerealDeserializer a
<?> String
l = Get a -> CerealDeserializer a
forall α. Get α -> CerealDeserializer α
CerealDeserializer (String -> Get a -> Get a
forall a. String -> Get a -> Get a
S.label String
l (CerealDeserializer a -> Get a
forall α. CerealDeserializer α -> Get α
cerealDeserializer CerealDeserializer a
p))
{-# INLINE (<?>) #-}
skipMany :: CerealDeserializer a -> CerealDeserializer ()
skipMany CerealDeserializer a
p = ((Bool
True Bool -> CerealDeserializer a -> CerealDeserializer Bool
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ CerealDeserializer a
p) CerealDeserializer Bool
-> CerealDeserializer Bool -> CerealDeserializer Bool
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Bool -> CerealDeserializer Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
False) CerealDeserializer Bool
-> (Bool -> CerealDeserializer ()) -> CerealDeserializer ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Bool
True → CerealDeserializer a -> CerealDeserializer ()
forall (m :: * -> *) a. Parsing m => m a -> m ()
skipMany CerealDeserializer a
p
Bool
False → () -> CerealDeserializer ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
unexpected :: String -> CerealDeserializer a
unexpected = Get a -> CerealDeserializer a
forall α. Get α -> CerealDeserializer α
CerealDeserializer (Get a -> CerealDeserializer a)
-> (String -> Get a) -> String -> CerealDeserializer a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Get a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail
{-# INLINE unexpected #-}
eof :: CerealDeserializer ()
eof = Get () -> CerealDeserializer ()
forall α. Get α -> CerealDeserializer α
CerealDeserializer
(Get () -> CerealDeserializer ())
-> Get () -> CerealDeserializer ()
forall a b. (a -> b) -> a -> b
$ ((Bool
False Bool -> Get (Maybe Any) -> Get Bool
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Get (Maybe Any) -> Get (Maybe Any)
forall a. Get (Maybe a) -> Get (Maybe a)
S.lookAheadM (Maybe Any
forall a. Maybe a
Nothing Maybe Any -> Get Word8 -> Get (Maybe Any)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Get Word8
S.getWord8)) Get Bool -> Get Bool -> Get Bool
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
Bool -> Get Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
True) Get Bool -> (Bool -> Get ()) -> Get ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Bool
True → () -> Get ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Bool
False → String -> Get ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Parsing.eof"
{-# INLINABLE eof #-}
notFollowedBy :: CerealDeserializer a -> CerealDeserializer ()
notFollowedBy CerealDeserializer a
p = Get () -> CerealDeserializer ()
forall α. Get α -> CerealDeserializer α
CerealDeserializer
(Get () -> CerealDeserializer ())
-> Get () -> CerealDeserializer ()
forall a b. (a -> b) -> a -> b
$ (Get (Either a ()) -> Get (Either a ())
forall a b. Get (Either a b) -> Get (Either a b)
S.lookAheadE (a -> Either a ()
forall a b. a -> Either a b
Left (a -> Either a ()) -> Get a -> Get (Either a ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (CerealDeserializer a -> Get a
forall α. CerealDeserializer α -> Get α
cerealDeserializer CerealDeserializer a
p)) Get (Either a ()) -> Get (Either a ()) -> Get (Either a ())
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
Either a () -> Get (Either a ())
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> Either a ()
forall a b. b -> Either a b
Right ())) Get (Either a ()) -> (Either a () -> Get ()) -> Get ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Left a
e → String -> Get ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (a -> String
forall a. Show a => a -> String
show a
e)
Right ()
_ → () -> Get ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
{-# INLINABLE notFollowedBy #-}
instance LookAheadParsing CerealDeserializer where
lookAhead :: CerealDeserializer a -> CerealDeserializer a
lookAhead = Get a -> CerealDeserializer a
forall α. Get α -> CerealDeserializer α
CerealDeserializer (Get a -> CerealDeserializer a)
-> (CerealDeserializer a -> Get a)
-> CerealDeserializer a
-> CerealDeserializer a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Get a -> Get a
forall a. Get a -> Get a
S.lookAhead (Get a -> Get a)
-> (CerealDeserializer a -> Get a) -> CerealDeserializer a -> Get a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CerealDeserializer a -> Get a
forall α. CerealDeserializer α -> Get α
cerealDeserializer
{-# INLINE lookAhead #-}
instance Deserializer CerealDeserializer where
word8 :: CerealDeserializer Word8
word8 = Get Word8 -> CerealDeserializer Word8
forall α. Get α -> CerealDeserializer α
CerealDeserializer Get Word8
S.getWord8
{-# INLINE word8 #-}
word16L :: CerealDeserializer Word16
word16L = Get Word16 -> CerealDeserializer Word16
forall α. Get α -> CerealDeserializer α
CerealDeserializer Get Word16
S.getWord16le
{-# INLINE word16L #-}
word16B :: CerealDeserializer Word16
word16B = Get Word16 -> CerealDeserializer Word16
forall α. Get α -> CerealDeserializer α
CerealDeserializer Get Word16
S.getWord16be
{-# INLINE word16B #-}
word32L :: CerealDeserializer Word32
word32L = Get Word32 -> CerealDeserializer Word32
forall α. Get α -> CerealDeserializer α
CerealDeserializer Get Word32
S.getWord32le
{-# INLINE word32L #-}
word32B :: CerealDeserializer Word32
word32B = Get Word32 -> CerealDeserializer Word32
forall α. Get α -> CerealDeserializer α
CerealDeserializer Get Word32
S.getWord32be
{-# INLINE word32B #-}
word64L :: CerealDeserializer Word64
word64L = Get Word64 -> CerealDeserializer Word64
forall α. Get α -> CerealDeserializer α
CerealDeserializer Get Word64
S.getWord64le
{-# INLINE word64L #-}
word64B :: CerealDeserializer Word64
word64B = Get Word64 -> CerealDeserializer Word64
forall α. Get α -> CerealDeserializer α
CerealDeserializer Get Word64
S.getWord64be
{-# INLINE word64B #-}
skip :: Int -> CerealDeserializer ()
skip = Get () -> CerealDeserializer ()
forall α. Get α -> CerealDeserializer α
CerealDeserializer (Get () -> CerealDeserializer ())
-> (Int -> Get ()) -> Int -> CerealDeserializer ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Get ()
S.skip
{-# INLINE skip #-}
ensure :: Int -> CerealDeserializer ByteString
ensure = Get ByteString -> CerealDeserializer ByteString
forall α. Get α -> CerealDeserializer α
CerealDeserializer (Get ByteString -> CerealDeserializer ByteString)
-> (Int -> Get ByteString) -> Int -> CerealDeserializer ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Get ByteString
S.ensure
{-# INLINE ensure #-}
take :: Int -> CerealDeserializer ByteString
take = Get ByteString -> CerealDeserializer ByteString
forall α. Get α -> CerealDeserializer α
CerealDeserializer (Get ByteString -> CerealDeserializer ByteString)
-> (Int -> Get ByteString) -> Int -> CerealDeserializer ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Get ByteString
S.getBytes
{-# INLINE take #-}
chunk :: CerealDeserializer ByteString
chunk = Get ByteString -> CerealDeserializer ByteString
forall α. Get α -> CerealDeserializer α
CerealDeserializer
(Get ByteString -> CerealDeserializer ByteString)
-> Get ByteString -> CerealDeserializer ByteString
forall a b. (a -> b) -> a -> b
$ (Get ByteString -> Get ByteString -> Get ByteString
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ByteString -> Get ByteString
forall (f :: * -> *) a. Applicative f => a -> f a
pure ByteString
BS.empty)
(Get ByteString -> Get ByteString)
-> Get ByteString -> Get ByteString
forall a b. (a -> b) -> a -> b
$ do ByteString
bs ← Int -> Get ByteString
S.ensure Int
1
Int -> Get ()
S.uncheckedSkip (ByteString -> Int
BS.length ByteString
bs)
ByteString -> Get ByteString
forall (m :: * -> *) a. Monad m => a -> m a
return ByteString
bs
{-# INLINE chunk #-}
isolate :: Int -> CerealDeserializer α -> CerealDeserializer α
isolate Int
n CerealDeserializer α
d = Get α -> CerealDeserializer α
forall α. Get α -> CerealDeserializer α
CerealDeserializer (Int -> Get α -> Get α
forall a. Int -> Get a -> Get a
S.isolate Int
n (CerealDeserializer α -> Get α
forall α. CerealDeserializer α -> Get α
cerealDeserializer CerealDeserializer α
d))
{-# INLINE isolate #-}
word16H ∷ Deserializer μ ⇒ μ Word16
#ifdef WORDS_BIGENDIAN
word16H = word16B
#else
word16H :: μ Word16
word16H = μ Word16
forall (μ :: * -> *). Deserializer μ => μ Word16
word16L
#endif
{-# INLINE word16H #-}
word32H ∷ Deserializer μ ⇒ μ Word32
#ifdef WORDS_BIGENDIAN
word32H = word32B
#else
word32H :: μ Word32
word32H = μ Word32
forall (μ :: * -> *). Deserializer μ => μ Word32
word32L
#endif
{-# INLINE word32H #-}
word64H ∷ Deserializer μ ⇒ μ Word64
#ifdef WORDS_BIGENDIAN
word64H = word64B
#else
word64H :: μ Word64
word64H = μ Word64
forall (μ :: * -> *). Deserializer μ => μ Word64
word64L
#endif
{-# INLINE word64H #-}
word ∷ Deserializer μ ⇒ μ Word
#if WORD_SIZE_IN_BITS == 32
word = fromIntegral <$> word32
#else
word :: μ Word
word = Word64 -> Word
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64 -> Word) -> μ Word64 -> μ Word
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word64
forall (μ :: * -> *). Deserializer μ => μ Word64
word64
#endif
{-# INLINE word #-}
wordL ∷ Deserializer μ ⇒ μ Word
#if WORD_SIZE_IN_BITS == 32
wordL = fromIntegral <$> word32L
#else
wordL :: μ Word
wordL = Word64 -> Word
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64 -> Word) -> μ Word64 -> μ Word
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word64
forall (μ :: * -> *). Deserializer μ => μ Word64
word64L
#endif
{-# INLINE wordL #-}
wordB ∷ Deserializer μ ⇒ μ Word
#if WORD_SIZE_IN_BITS == 32
wordB = fromIntegral <$> word32B
#else
wordB :: μ Word
wordB = Word64 -> Word
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64 -> Word) -> μ Word64 -> μ Word
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word64
forall (μ :: * -> *). Deserializer μ => μ Word64
word64B
#endif
{-# INLINE wordB #-}
wordH ∷ Deserializer μ ⇒ μ Word
#ifdef WORDS_BIGENDIAN
wordH = wordB
#else
wordH :: μ Word
wordH = μ Word
forall (μ :: * -> *). Deserializer μ => μ Word
wordL
#endif
{-# INLINE wordH #-}
int8 ∷ Deserializer μ ⇒ μ Int8
int8 :: μ Int8
int8 = Word8 -> Int8
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word8 -> Int8) -> μ Word8 -> μ Int8
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word8
forall (μ :: * -> *). Deserializer μ => μ Word8
word8
{-# INLINE int8 #-}
int16 ∷ Deserializer μ ⇒ μ Int16
int16 :: μ Int16
int16 = Word16 -> Int16
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word16 -> Int16) -> μ Word16 -> μ Int16
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word16
forall (μ :: * -> *). Deserializer μ => μ Word16
word16
{-# INLINE int16 #-}
int16L ∷ Deserializer μ ⇒ μ Int16
int16L :: μ Int16
int16L = Word16 -> Int16
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word16 -> Int16) -> μ Word16 -> μ Int16
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word16
forall (μ :: * -> *). Deserializer μ => μ Word16
word16L
{-# INLINE int16L #-}
int16B ∷ Deserializer μ ⇒ μ Int16
int16B :: μ Int16
int16B = Word16 -> Int16
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word16 -> Int16) -> μ Word16 -> μ Int16
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word16
forall (μ :: * -> *). Deserializer μ => μ Word16
word16B
{-# INLINE int16B #-}
int16H ∷ Deserializer μ ⇒ μ Int16
int16H :: μ Int16
int16H = Word16 -> Int16
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word16 -> Int16) -> μ Word16 -> μ Int16
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word16
forall (μ :: * -> *). Deserializer μ => μ Word16
word16H
{-# INLINE int16H #-}
int32 ∷ Deserializer μ ⇒ μ Int32
int32 :: μ Int32
int32 = Word32 -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word32 -> Int32) -> μ Word32 -> μ Int32
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word32
forall (μ :: * -> *). Deserializer μ => μ Word32
word32
{-# INLINE int32 #-}
int32L ∷ Deserializer μ ⇒ μ Int32
int32L :: μ Int32
int32L = Word32 -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word32 -> Int32) -> μ Word32 -> μ Int32
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word32
forall (μ :: * -> *). Deserializer μ => μ Word32
word32L
{-# INLINE int32L #-}
int32B ∷ Deserializer μ ⇒ μ Int32
int32B :: μ Int32
int32B = Word32 -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word32 -> Int32) -> μ Word32 -> μ Int32
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word32
forall (μ :: * -> *). Deserializer μ => μ Word32
word32B
{-# INLINE int32B #-}
int32H ∷ Deserializer μ ⇒ μ Int32
int32H :: μ Int32
int32H = Word32 -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word32 -> Int32) -> μ Word32 -> μ Int32
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word32
forall (μ :: * -> *). Deserializer μ => μ Word32
word32H
{-# INLINE int32H #-}
int64 ∷ Deserializer μ ⇒ μ Int64
int64 :: μ Int64
int64 = Word64 -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64 -> Int64) -> μ Word64 -> μ Int64
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word64
forall (μ :: * -> *). Deserializer μ => μ Word64
word64
{-# INLINE int64 #-}
int64L ∷ Deserializer μ ⇒ μ Int64
int64L :: μ Int64
int64L = Word64 -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64 -> Int64) -> μ Word64 -> μ Int64
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word64
forall (μ :: * -> *). Deserializer μ => μ Word64
word64L
{-# INLINE int64L #-}
int64B ∷ Deserializer μ ⇒ μ Int64
int64B :: μ Int64
int64B = Word64 -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64 -> Int64) -> μ Word64 -> μ Int64
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word64
forall (μ :: * -> *). Deserializer μ => μ Word64
word64B
{-# INLINE int64B #-}
int64H ∷ Deserializer μ ⇒ μ Int64
int64H :: μ Int64
int64H = Word64 -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64 -> Int64) -> μ Word64 -> μ Int64
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Word64
forall (μ :: * -> *). Deserializer μ => μ Word64
word64H
{-# INLINE int64H #-}
int ∷ Deserializer μ ⇒ μ Int
#if WORD_SIZE_IN_BITS == 32
int = fromIntegral <$> int32
#else
int :: μ Int
int = Int64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> Int) -> μ Int64 -> μ Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Int64
forall (μ :: * -> *). Deserializer μ => μ Int64
int64
#endif
{-# INLINE int #-}
intL ∷ Deserializer μ ⇒ μ Int
#if WORD_SIZE_IN_BITS == 32
intL = fromIntegral <$> int32L
#else
intL :: μ Int
intL = Int64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> Int) -> μ Int64 -> μ Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Int64
forall (μ :: * -> *). Deserializer μ => μ Int64
int64L
#endif
{-# INLINE intL #-}
intB ∷ Deserializer μ ⇒ μ Int
#if WORD_SIZE_IN_BITS == 32
intB = fromIntegral <$> int32B
#else
intB :: μ Int
intB = Int64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> Int) -> μ Int64 -> μ Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Int64
forall (μ :: * -> *). Deserializer μ => μ Int64
int64B
#endif
{-# INLINE intB #-}
intH ∷ Deserializer μ ⇒ μ Int
#if WORD_SIZE_IN_BITS == 32
intH = fromIntegral <$> int32H
#else
intH :: μ Int
intH = Int64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> Int) -> μ Int64 -> μ Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ Int64
forall (μ :: * -> *). Deserializer μ => μ Int64
int64H
#endif
{-# INLINE intH #-}
label ∷ Parsing μ ⇒ String → μ α → μ α
label :: String -> μ α -> μ α
label = (μ α -> String -> μ α) -> String -> μ α -> μ α
forall a b c. (a -> b -> c) -> b -> a -> c
flip μ α -> String -> μ α
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
(<?>)
{-# INLINE label #-}
newtype LittleEndianDeserializer μ α =
LittleEndianDeserializer { LittleEndianDeserializer μ α -> μ α
deserializeL ∷ μ α }
deriving (Typeable, Typeable (LittleEndianDeserializer μ α)
DataType
Constr
Typeable (LittleEndianDeserializer μ α)
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> LittleEndianDeserializer μ α
-> c (LittleEndianDeserializer μ α))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c (LittleEndianDeserializer μ α))
-> (LittleEndianDeserializer μ α -> Constr)
-> (LittleEndianDeserializer μ α -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c (LittleEndianDeserializer μ α)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (LittleEndianDeserializer μ α)))
-> ((forall b. Data b => b -> b)
-> LittleEndianDeserializer μ α -> LittleEndianDeserializer μ α)
-> (forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> LittleEndianDeserializer μ α
-> r)
-> (forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> LittleEndianDeserializer μ α
-> r)
-> (forall u.
(forall d. Data d => d -> u)
-> LittleEndianDeserializer μ α -> [u])
-> (forall u.
Int
-> (forall d. Data d => d -> u)
-> LittleEndianDeserializer μ α
-> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> LittleEndianDeserializer μ α
-> m (LittleEndianDeserializer μ α))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> LittleEndianDeserializer μ α
-> m (LittleEndianDeserializer μ α))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> LittleEndianDeserializer μ α
-> m (LittleEndianDeserializer μ α))
-> Data (LittleEndianDeserializer μ α)
LittleEndianDeserializer μ α -> DataType
LittleEndianDeserializer μ α -> Constr
(forall b. Data b => b -> b)
-> LittleEndianDeserializer μ α -> LittleEndianDeserializer μ α
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> LittleEndianDeserializer μ α
-> c (LittleEndianDeserializer μ α)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c (LittleEndianDeserializer μ α)
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int
-> (forall d. Data d => d -> u)
-> LittleEndianDeserializer μ α
-> u
forall u.
(forall d. Data d => d -> u) -> LittleEndianDeserializer μ α -> [u]
forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> LittleEndianDeserializer μ α
-> r
forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> LittleEndianDeserializer μ α
-> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> LittleEndianDeserializer μ α -> m (LittleEndianDeserializer μ α)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> LittleEndianDeserializer μ α -> m (LittleEndianDeserializer μ α)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c (LittleEndianDeserializer μ α)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> LittleEndianDeserializer μ α
-> c (LittleEndianDeserializer μ α)
forall (μ :: * -> *) α.
(Typeable μ, Typeable α, Data (μ α)) =>
Typeable (LittleEndianDeserializer μ α)
forall (μ :: * -> *) α.
(Typeable μ, Typeable α, Data (μ α)) =>
LittleEndianDeserializer μ α -> DataType
forall (μ :: * -> *) α.
(Typeable μ, Typeable α, Data (μ α)) =>
LittleEndianDeserializer μ α -> Constr
forall (μ :: * -> *) α.
(Typeable μ, Typeable α, Data (μ α)) =>
(forall b. Data b => b -> b)
-> LittleEndianDeserializer μ α -> LittleEndianDeserializer μ α
forall (μ :: * -> *) α u.
(Typeable μ, Typeable α, Data (μ α)) =>
Int
-> (forall d. Data d => d -> u)
-> LittleEndianDeserializer μ α
-> u
forall (μ :: * -> *) α u.
(Typeable μ, Typeable α, Data (μ α)) =>
(forall d. Data d => d -> u) -> LittleEndianDeserializer μ α -> [u]
forall (μ :: * -> *) α r r'.
(Typeable μ, Typeable α, Data (μ α)) =>
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> LittleEndianDeserializer μ α
-> r
forall (μ :: * -> *) α r r'.
(Typeable μ, Typeable α, Data (μ α)) =>
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> LittleEndianDeserializer μ α
-> r
forall (μ :: * -> *) α (m :: * -> *).
(Typeable μ, Typeable α, Data (μ α), Monad m) =>
(forall d. Data d => d -> m d)
-> LittleEndianDeserializer μ α -> m (LittleEndianDeserializer μ α)
forall (μ :: * -> *) α (m :: * -> *).
(Typeable μ, Typeable α, Data (μ α), MonadPlus m) =>
(forall d. Data d => d -> m d)
-> LittleEndianDeserializer μ α -> m (LittleEndianDeserializer μ α)
forall (μ :: * -> *) α (c :: * -> *).
(Typeable μ, Typeable α, Data (μ α)) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c (LittleEndianDeserializer μ α)
forall (μ :: * -> *) α (c :: * -> *).
(Typeable μ, Typeable α, Data (μ α)) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> LittleEndianDeserializer μ α
-> c (LittleEndianDeserializer μ α)
forall (μ :: * -> *) α (t :: * -> *) (c :: * -> *).
(Typeable μ, Typeable α, Data (μ α), Typeable t) =>
(forall d. Data d => c (t d))
-> Maybe (c (LittleEndianDeserializer μ α))
forall (μ :: * -> *) α (t :: * -> * -> *) (c :: * -> *).
(Typeable μ, Typeable α, Data (μ α), Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (LittleEndianDeserializer μ α))
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c (LittleEndianDeserializer μ α))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (LittleEndianDeserializer μ α))
$cLittleEndianDeserializer :: Constr
$tLittleEndianDeserializer :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> LittleEndianDeserializer μ α -> m (LittleEndianDeserializer μ α)
$cgmapMo :: forall (μ :: * -> *) α (m :: * -> *).
(Typeable μ, Typeable α, Data (μ α), MonadPlus m) =>
(forall d. Data d => d -> m d)
-> LittleEndianDeserializer μ α -> m (LittleEndianDeserializer μ α)
gmapMp :: (forall d. Data d => d -> m d)
-> LittleEndianDeserializer μ α -> m (LittleEndianDeserializer μ α)
$cgmapMp :: forall (μ :: * -> *) α (m :: * -> *).
(Typeable μ, Typeable α, Data (μ α), MonadPlus m) =>
(forall d. Data d => d -> m d)
-> LittleEndianDeserializer μ α -> m (LittleEndianDeserializer μ α)
gmapM :: (forall d. Data d => d -> m d)
-> LittleEndianDeserializer μ α -> m (LittleEndianDeserializer μ α)
$cgmapM :: forall (μ :: * -> *) α (m :: * -> *).
(Typeable μ, Typeable α, Data (μ α), Monad m) =>
(forall d. Data d => d -> m d)
-> LittleEndianDeserializer μ α -> m (LittleEndianDeserializer μ α)
gmapQi :: Int
-> (forall d. Data d => d -> u)
-> LittleEndianDeserializer μ α
-> u
$cgmapQi :: forall (μ :: * -> *) α u.
(Typeable μ, Typeable α, Data (μ α)) =>
Int
-> (forall d. Data d => d -> u)
-> LittleEndianDeserializer μ α
-> u
gmapQ :: (forall d. Data d => d -> u) -> LittleEndianDeserializer μ α -> [u]
$cgmapQ :: forall (μ :: * -> *) α u.
(Typeable μ, Typeable α, Data (μ α)) =>
(forall d. Data d => d -> u) -> LittleEndianDeserializer μ α -> [u]
gmapQr :: (r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> LittleEndianDeserializer μ α
-> r
$cgmapQr :: forall (μ :: * -> *) α r r'.
(Typeable μ, Typeable α, Data (μ α)) =>
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> LittleEndianDeserializer μ α
-> r
gmapQl :: (r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> LittleEndianDeserializer μ α
-> r
$cgmapQl :: forall (μ :: * -> *) α r r'.
(Typeable μ, Typeable α, Data (μ α)) =>
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> LittleEndianDeserializer μ α
-> r
gmapT :: (forall b. Data b => b -> b)
-> LittleEndianDeserializer μ α -> LittleEndianDeserializer μ α
$cgmapT :: forall (μ :: * -> *) α.
(Typeable μ, Typeable α, Data (μ α)) =>
(forall b. Data b => b -> b)
-> LittleEndianDeserializer μ α -> LittleEndianDeserializer μ α
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (LittleEndianDeserializer μ α))
$cdataCast2 :: forall (μ :: * -> *) α (t :: * -> * -> *) (c :: * -> *).
(Typeable μ, Typeable α, Data (μ α), Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (LittleEndianDeserializer μ α))
dataCast1 :: (forall d. Data d => c (t d))
-> Maybe (c (LittleEndianDeserializer μ α))
$cdataCast1 :: forall (μ :: * -> *) α (t :: * -> *) (c :: * -> *).
(Typeable μ, Typeable α, Data (μ α), Typeable t) =>
(forall d. Data d => c (t d))
-> Maybe (c (LittleEndianDeserializer μ α))
dataTypeOf :: LittleEndianDeserializer μ α -> DataType
$cdataTypeOf :: forall (μ :: * -> *) α.
(Typeable μ, Typeable α, Data (μ α)) =>
LittleEndianDeserializer μ α -> DataType
toConstr :: LittleEndianDeserializer μ α -> Constr
$ctoConstr :: forall (μ :: * -> *) α.
(Typeable μ, Typeable α, Data (μ α)) =>
LittleEndianDeserializer μ α -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c (LittleEndianDeserializer μ α)
$cgunfold :: forall (μ :: * -> *) α (c :: * -> *).
(Typeable μ, Typeable α, Data (μ α)) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c (LittleEndianDeserializer μ α)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> LittleEndianDeserializer μ α
-> c (LittleEndianDeserializer μ α)
$cgfoldl :: forall (μ :: * -> *) α (c :: * -> *).
(Typeable μ, Typeable α, Data (μ α)) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> LittleEndianDeserializer μ α
-> c (LittleEndianDeserializer μ α)
$cp1Data :: forall (μ :: * -> *) α.
(Typeable μ, Typeable α, Data (μ α)) =>
Typeable (LittleEndianDeserializer μ α)
Data, (forall x.
LittleEndianDeserializer μ α
-> Rep (LittleEndianDeserializer μ α) x)
-> (forall x.
Rep (LittleEndianDeserializer μ α) x
-> LittleEndianDeserializer μ α)
-> Generic (LittleEndianDeserializer μ α)
forall x.
Rep (LittleEndianDeserializer μ α) x
-> LittleEndianDeserializer μ α
forall x.
LittleEndianDeserializer μ α
-> Rep (LittleEndianDeserializer μ α) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (μ :: * -> *) α x.
Rep (LittleEndianDeserializer μ α) x
-> LittleEndianDeserializer μ α
forall (μ :: * -> *) α x.
LittleEndianDeserializer μ α
-> Rep (LittleEndianDeserializer μ α) x
$cto :: forall (μ :: * -> *) α x.
Rep (LittleEndianDeserializer μ α) x
-> LittleEndianDeserializer μ α
$cfrom :: forall (μ :: * -> *) α x.
LittleEndianDeserializer μ α
-> Rep (LittleEndianDeserializer μ α) x
Generic, a -> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ a
(a -> b)
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ b
(forall a b.
(a -> b)
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ b)
-> (forall a b.
a -> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ a)
-> Functor (LittleEndianDeserializer μ)
forall a b.
a -> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ a
forall a b.
(a -> b)
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ b
forall (μ :: * -> *) a b.
Functor μ =>
a -> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ a
forall (μ :: * -> *) a b.
Functor μ =>
(a -> b)
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ a
$c<$ :: forall (μ :: * -> *) a b.
Functor μ =>
a -> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ a
fmap :: (a -> b)
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ b
$cfmap :: forall (μ :: * -> *) a b.
Functor μ =>
(a -> b)
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ b
Functor, Functor (LittleEndianDeserializer μ)
a -> LittleEndianDeserializer μ a
Functor (LittleEndianDeserializer μ)
-> (forall a. a -> LittleEndianDeserializer μ a)
-> (forall a b.
LittleEndianDeserializer μ (a -> b)
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ b)
-> (forall a b c.
(a -> b -> c)
-> LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b
-> LittleEndianDeserializer μ c)
-> (forall a b.
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ b)
-> (forall a b.
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ a)
-> Applicative (LittleEndianDeserializer μ)
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ b
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ a
LittleEndianDeserializer μ (a -> b)
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ b
(a -> b -> c)
-> LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b
-> LittleEndianDeserializer μ c
forall a. a -> LittleEndianDeserializer μ a
forall a b.
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ a
forall a b.
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ b
forall a b.
LittleEndianDeserializer μ (a -> b)
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ b
forall a b c.
(a -> b -> c)
-> LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b
-> LittleEndianDeserializer μ c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
forall (μ :: * -> *).
Applicative μ =>
Functor (LittleEndianDeserializer μ)
forall (μ :: * -> *) a.
Applicative μ =>
a -> LittleEndianDeserializer μ a
forall (μ :: * -> *) a b.
Applicative μ =>
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ a
forall (μ :: * -> *) a b.
Applicative μ =>
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ b
forall (μ :: * -> *) a b.
Applicative μ =>
LittleEndianDeserializer μ (a -> b)
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ b
forall (μ :: * -> *) a b c.
Applicative μ =>
(a -> b -> c)
-> LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b
-> LittleEndianDeserializer μ c
<* :: LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ a
$c<* :: forall (μ :: * -> *) a b.
Applicative μ =>
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ a
*> :: LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ b
$c*> :: forall (μ :: * -> *) a b.
Applicative μ =>
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ b
liftA2 :: (a -> b -> c)
-> LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b
-> LittleEndianDeserializer μ c
$cliftA2 :: forall (μ :: * -> *) a b c.
Applicative μ =>
(a -> b -> c)
-> LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b
-> LittleEndianDeserializer μ c
<*> :: LittleEndianDeserializer μ (a -> b)
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ b
$c<*> :: forall (μ :: * -> *) a b.
Applicative μ =>
LittleEndianDeserializer μ (a -> b)
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ b
pure :: a -> LittleEndianDeserializer μ a
$cpure :: forall (μ :: * -> *) a.
Applicative μ =>
a -> LittleEndianDeserializer μ a
$cp1Applicative :: forall (μ :: * -> *).
Applicative μ =>
Functor (LittleEndianDeserializer μ)
Applicative,
Applicative (LittleEndianDeserializer μ)
LittleEndianDeserializer μ a
Applicative (LittleEndianDeserializer μ)
-> (forall a. LittleEndianDeserializer μ a)
-> (forall a.
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a)
-> (forall a.
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ [a])
-> (forall a.
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ [a])
-> Alternative (LittleEndianDeserializer μ)
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ [a]
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ [a]
forall a. LittleEndianDeserializer μ a
forall a.
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ [a]
forall a.
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a
forall (f :: * -> *).
Applicative f
-> (forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
forall (μ :: * -> *).
Alternative μ =>
Applicative (LittleEndianDeserializer μ)
forall (μ :: * -> *) a.
Alternative μ =>
LittleEndianDeserializer μ a
forall (μ :: * -> *) a.
Alternative μ =>
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ [a]
forall (μ :: * -> *) a.
Alternative μ =>
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a
many :: LittleEndianDeserializer μ a -> LittleEndianDeserializer μ [a]
$cmany :: forall (μ :: * -> *) a.
Alternative μ =>
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ [a]
some :: LittleEndianDeserializer μ a -> LittleEndianDeserializer μ [a]
$csome :: forall (μ :: * -> *) a.
Alternative μ =>
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ [a]
<|> :: LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a
$c<|> :: forall (μ :: * -> *) a.
Alternative μ =>
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a
empty :: LittleEndianDeserializer μ a
$cempty :: forall (μ :: * -> *) a.
Alternative μ =>
LittleEndianDeserializer μ a
$cp1Alternative :: forall (μ :: * -> *).
Alternative μ =>
Applicative (LittleEndianDeserializer μ)
Alternative, Applicative (LittleEndianDeserializer μ)
a -> LittleEndianDeserializer μ a
Applicative (LittleEndianDeserializer μ)
-> (forall a b.
LittleEndianDeserializer μ a
-> (a -> LittleEndianDeserializer μ b)
-> LittleEndianDeserializer μ b)
-> (forall a b.
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ b)
-> (forall a. a -> LittleEndianDeserializer μ a)
-> Monad (LittleEndianDeserializer μ)
LittleEndianDeserializer μ a
-> (a -> LittleEndianDeserializer μ b)
-> LittleEndianDeserializer μ b
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ b
forall a. a -> LittleEndianDeserializer μ a
forall a b.
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ b
forall a b.
LittleEndianDeserializer μ a
-> (a -> LittleEndianDeserializer μ b)
-> LittleEndianDeserializer μ b
forall (μ :: * -> *).
Monad μ =>
Applicative (LittleEndianDeserializer μ)
forall (μ :: * -> *) a.
Monad μ =>
a -> LittleEndianDeserializer μ a
forall (μ :: * -> *) a b.
Monad μ =>
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ b
forall (μ :: * -> *) a b.
Monad μ =>
LittleEndianDeserializer μ a
-> (a -> LittleEndianDeserializer μ b)
-> LittleEndianDeserializer μ b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> LittleEndianDeserializer μ a
$creturn :: forall (μ :: * -> *) a.
Monad μ =>
a -> LittleEndianDeserializer μ a
>> :: LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ b
$c>> :: forall (μ :: * -> *) a b.
Monad μ =>
LittleEndianDeserializer μ a
-> LittleEndianDeserializer μ b -> LittleEndianDeserializer μ b
>>= :: LittleEndianDeserializer μ a
-> (a -> LittleEndianDeserializer μ b)
-> LittleEndianDeserializer μ b
$c>>= :: forall (μ :: * -> *) a b.
Monad μ =>
LittleEndianDeserializer μ a
-> (a -> LittleEndianDeserializer μ b)
-> LittleEndianDeserializer μ b
$cp1Monad :: forall (μ :: * -> *).
Monad μ =>
Applicative (LittleEndianDeserializer μ)
Monad, Alternative (LittleEndianDeserializer μ)
LittleEndianDeserializer μ ()
String -> LittleEndianDeserializer μ a
Alternative (LittleEndianDeserializer μ)
-> (forall a.
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a)
-> (forall a.
LittleEndianDeserializer μ a
-> String -> LittleEndianDeserializer μ a)
-> (forall a.
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ ())
-> (forall a.
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ ())
-> (forall a. String -> LittleEndianDeserializer μ a)
-> LittleEndianDeserializer μ ()
-> (forall a.
Show a =>
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ ())
-> Parsing (LittleEndianDeserializer μ)
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a
LittleEndianDeserializer μ a
-> String -> LittleEndianDeserializer μ a
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ ()
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ ()
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ ()
forall a.
Show a =>
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ ()
forall a. String -> LittleEndianDeserializer μ a
forall a.
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a
forall a.
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ ()
forall a.
LittleEndianDeserializer μ a
-> String -> LittleEndianDeserializer μ a
forall (m :: * -> *).
Alternative m
-> (forall a. m a -> m a)
-> (forall a. m a -> String -> m a)
-> (forall a. m a -> m ())
-> (forall a. m a -> m ())
-> (forall a. String -> m a)
-> m ()
-> (forall a. Show a => m a -> m ())
-> Parsing m
forall (μ :: * -> *).
Parsing μ =>
Alternative (LittleEndianDeserializer μ)
forall (μ :: * -> *). Parsing μ => LittleEndianDeserializer μ ()
forall (μ :: * -> *) a.
(Parsing μ, Show a) =>
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ ()
forall (μ :: * -> *) a.
Parsing μ =>
String -> LittleEndianDeserializer μ a
forall (μ :: * -> *) a.
Parsing μ =>
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a
forall (μ :: * -> *) a.
Parsing μ =>
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ ()
forall (μ :: * -> *) a.
Parsing μ =>
LittleEndianDeserializer μ a
-> String -> LittleEndianDeserializer μ a
notFollowedBy :: LittleEndianDeserializer μ a -> LittleEndianDeserializer μ ()
$cnotFollowedBy :: forall (μ :: * -> *) a.
(Parsing μ, Show a) =>
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ ()
eof :: LittleEndianDeserializer μ ()
$ceof :: forall (μ :: * -> *). Parsing μ => LittleEndianDeserializer μ ()
unexpected :: String -> LittleEndianDeserializer μ a
$cunexpected :: forall (μ :: * -> *) a.
Parsing μ =>
String -> LittleEndianDeserializer μ a
skipSome :: LittleEndianDeserializer μ a -> LittleEndianDeserializer μ ()
$cskipSome :: forall (μ :: * -> *) a.
Parsing μ =>
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ ()
skipMany :: LittleEndianDeserializer μ a -> LittleEndianDeserializer μ ()
$cskipMany :: forall (μ :: * -> *) a.
Parsing μ =>
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ ()
<?> :: LittleEndianDeserializer μ a
-> String -> LittleEndianDeserializer μ a
$c<?> :: forall (μ :: * -> *) a.
Parsing μ =>
LittleEndianDeserializer μ a
-> String -> LittleEndianDeserializer μ a
try :: LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a
$ctry :: forall (μ :: * -> *) a.
Parsing μ =>
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a
$cp1Parsing :: forall (μ :: * -> *).
Parsing μ =>
Alternative (LittleEndianDeserializer μ)
Parsing, Parsing (LittleEndianDeserializer μ)
Parsing (LittleEndianDeserializer μ)
-> (forall a.
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a)
-> LookAheadParsing (LittleEndianDeserializer μ)
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a
forall a.
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a
forall (μ :: * -> *).
LookAheadParsing μ =>
Parsing (LittleEndianDeserializer μ)
forall (μ :: * -> *) a.
LookAheadParsing μ =>
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a
forall (m :: * -> *).
Parsing m -> (forall a. m a -> m a) -> LookAheadParsing m
lookAhead :: LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a
$clookAhead :: forall (μ :: * -> *) a.
LookAheadParsing μ =>
LittleEndianDeserializer μ a -> LittleEndianDeserializer μ a
$cp1LookAheadParsing :: forall (μ :: * -> *).
LookAheadParsing μ =>
Parsing (LittleEndianDeserializer μ)
LookAheadParsing)
instance Deserializer μ ⇒ Deserializer (LittleEndianDeserializer μ) where
endian :: Proxy (LittleEndianDeserializer μ) -> Endian
endian Proxy (LittleEndianDeserializer μ)
_ = Endian
LittleEndian
{-# INLINE endian #-}
word8 :: LittleEndianDeserializer μ Word8
word8 = μ Word8 -> LittleEndianDeserializer μ Word8
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer μ Word8
forall (μ :: * -> *). Deserializer μ => μ Word8
word8
{-# INLINE word8 #-}
word16 :: LittleEndianDeserializer μ Word16
word16 = μ Word16 -> LittleEndianDeserializer μ Word16
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer μ Word16
forall (μ :: * -> *). Deserializer μ => μ Word16
word16L
{-# INLINE word16 #-}
word32 :: LittleEndianDeserializer μ Word32
word32 = μ Word32 -> LittleEndianDeserializer μ Word32
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer μ Word32
forall (μ :: * -> *). Deserializer μ => μ Word32
word32L
{-# INLINE word32 #-}
word64 :: LittleEndianDeserializer μ Word64
word64 = μ Word64 -> LittleEndianDeserializer μ Word64
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer μ Word64
forall (μ :: * -> *). Deserializer μ => μ Word64
word64L
{-# INLINE word64 #-}
word16L :: LittleEndianDeserializer μ Word16
word16L = μ Word16 -> LittleEndianDeserializer μ Word16
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer μ Word16
forall (μ :: * -> *). Deserializer μ => μ Word16
word16L
{-# INLINE word16L #-}
word16B :: LittleEndianDeserializer μ Word16
word16B = μ Word16 -> LittleEndianDeserializer μ Word16
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer μ Word16
forall (μ :: * -> *). Deserializer μ => μ Word16
word16B
{-# INLINE word16B #-}
word32L :: LittleEndianDeserializer μ Word32
word32L = μ Word32 -> LittleEndianDeserializer μ Word32
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer μ Word32
forall (μ :: * -> *). Deserializer μ => μ Word32
word32L
{-# INLINE word32L #-}
word32B :: LittleEndianDeserializer μ Word32
word32B = μ Word32 -> LittleEndianDeserializer μ Word32
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer μ Word32
forall (μ :: * -> *). Deserializer μ => μ Word32
word32B
{-# INLINE word32B #-}
word64L :: LittleEndianDeserializer μ Word64
word64L = μ Word64 -> LittleEndianDeserializer μ Word64
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer μ Word64
forall (μ :: * -> *). Deserializer μ => μ Word64
word64L
{-# INLINE word64L #-}
word64B :: LittleEndianDeserializer μ Word64
word64B = μ Word64 -> LittleEndianDeserializer μ Word64
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer μ Word64
forall (μ :: * -> *). Deserializer μ => μ Word64
word64B
{-# INLINE word64B #-}
satisfy :: (Word8 -> Bool) -> LittleEndianDeserializer μ Word8
satisfy = μ Word8 -> LittleEndianDeserializer μ Word8
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer (μ Word8 -> LittleEndianDeserializer μ Word8)
-> ((Word8 -> Bool) -> μ Word8)
-> (Word8 -> Bool)
-> LittleEndianDeserializer μ Word8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word8 -> Bool) -> μ Word8
forall (μ :: * -> *). Deserializer μ => (Word8 -> Bool) -> μ Word8
satisfy
{-# INLINE satisfy #-}
byte :: Word8 -> LittleEndianDeserializer μ Word8
byte = μ Word8 -> LittleEndianDeserializer μ Word8
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer (μ Word8 -> LittleEndianDeserializer μ Word8)
-> (Word8 -> μ Word8) -> Word8 -> LittleEndianDeserializer μ Word8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> μ Word8
forall (μ :: * -> *). Deserializer μ => Word8 -> μ Word8
byte
{-# INLINE byte #-}
notByte :: Word8 -> LittleEndianDeserializer μ Word8
notByte = μ Word8 -> LittleEndianDeserializer μ Word8
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer (μ Word8 -> LittleEndianDeserializer μ Word8)
-> (Word8 -> μ Word8) -> Word8 -> LittleEndianDeserializer μ Word8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> μ Word8
forall (μ :: * -> *). Deserializer μ => Word8 -> μ Word8
notByte
{-# INLINE notByte #-}
bytes :: ByteString -> LittleEndianDeserializer μ ByteString
bytes = μ ByteString -> LittleEndianDeserializer μ ByteString
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer (μ ByteString -> LittleEndianDeserializer μ ByteString)
-> (ByteString -> μ ByteString)
-> ByteString
-> LittleEndianDeserializer μ ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> μ ByteString
forall (μ :: * -> *). Deserializer μ => ByteString -> μ ByteString
bytes
{-# INLINE bytes #-}
skip :: Int -> LittleEndianDeserializer μ ()
skip = μ () -> LittleEndianDeserializer μ ()
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer (μ () -> LittleEndianDeserializer μ ())
-> (Int -> μ ()) -> Int -> LittleEndianDeserializer μ ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> μ ()
forall (μ :: * -> *). Deserializer μ => Int -> μ ()
skip
{-# INLINE skip #-}
ensure :: Int -> LittleEndianDeserializer μ ByteString
ensure = μ ByteString -> LittleEndianDeserializer μ ByteString
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer (μ ByteString -> LittleEndianDeserializer μ ByteString)
-> (Int -> μ ByteString)
-> Int
-> LittleEndianDeserializer μ ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> μ ByteString
forall (μ :: * -> *). Deserializer μ => Int -> μ ByteString
ensure
{-# INLINE ensure #-}
ensure_ :: Int -> LittleEndianDeserializer μ ()
ensure_ = μ () -> LittleEndianDeserializer μ ()
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer (μ () -> LittleEndianDeserializer μ ())
-> (Int -> μ ()) -> Int -> LittleEndianDeserializer μ ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> μ ()
forall (μ :: * -> *). Deserializer μ => Int -> μ ()
ensure_
{-# INLINE ensure_ #-}
take :: Int -> LittleEndianDeserializer μ ByteString
take = μ ByteString -> LittleEndianDeserializer μ ByteString
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer (μ ByteString -> LittleEndianDeserializer μ ByteString)
-> (Int -> μ ByteString)
-> Int
-> LittleEndianDeserializer μ ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> μ ByteString
forall (μ :: * -> *). Deserializer μ => Int -> μ ByteString
take
{-# INLINE take #-}
chunk :: LittleEndianDeserializer μ ByteString
chunk = μ ByteString -> LittleEndianDeserializer μ ByteString
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer μ ByteString
forall (μ :: * -> *). Deserializer μ => μ ByteString
chunk
{-# INLINE chunk #-}
isolate :: Int -> LittleEndianDeserializer μ α -> LittleEndianDeserializer μ α
isolate Int
n = μ α -> LittleEndianDeserializer μ α
forall (μ :: * -> *) α. μ α -> LittleEndianDeserializer μ α
LittleEndianDeserializer (μ α -> LittleEndianDeserializer μ α)
-> (LittleEndianDeserializer μ α -> μ α)
-> LittleEndianDeserializer μ α
-> LittleEndianDeserializer μ α
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> μ α -> μ α
forall (μ :: * -> *) α. Deserializer μ => Int -> μ α -> μ α
isolate Int
n (μ α -> μ α)
-> (LittleEndianDeserializer μ α -> μ α)
-> LittleEndianDeserializer μ α
-> μ α
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LittleEndianDeserializer μ α -> μ α
forall (μ :: * -> *) α. LittleEndianDeserializer μ α -> μ α
deserializeL
{-# INLINE isolate #-}
newtype BigEndianDeserializer μ α =
BigEndianDeserializer { BigEndianDeserializer μ α -> μ α
deserializeB ∷ μ α }
deriving (Typeable, Typeable (BigEndianDeserializer μ α)
DataType
Constr
Typeable (BigEndianDeserializer μ α)
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> BigEndianDeserializer μ α
-> c (BigEndianDeserializer μ α))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (BigEndianDeserializer μ α))
-> (BigEndianDeserializer μ α -> Constr)
-> (BigEndianDeserializer μ α -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c (BigEndianDeserializer μ α)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (BigEndianDeserializer μ α)))
-> ((forall b. Data b => b -> b)
-> BigEndianDeserializer μ α -> BigEndianDeserializer μ α)
-> (forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> BigEndianDeserializer μ α
-> r)
-> (forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> BigEndianDeserializer μ α
-> r)
-> (forall u.
(forall d. Data d => d -> u) -> BigEndianDeserializer μ α -> [u])
-> (forall u.
Int
-> (forall d. Data d => d -> u) -> BigEndianDeserializer μ α -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> BigEndianDeserializer μ α -> m (BigEndianDeserializer μ α))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> BigEndianDeserializer μ α -> m (BigEndianDeserializer μ α))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> BigEndianDeserializer μ α -> m (BigEndianDeserializer μ α))
-> Data (BigEndianDeserializer μ α)
BigEndianDeserializer μ α -> DataType
BigEndianDeserializer μ α -> Constr
(forall b. Data b => b -> b)
-> BigEndianDeserializer μ α -> BigEndianDeserializer μ α
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> BigEndianDeserializer μ α
-> c (BigEndianDeserializer μ α)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (BigEndianDeserializer μ α)
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int
-> (forall d. Data d => d -> u) -> BigEndianDeserializer μ α -> u
forall u.
(forall d. Data d => d -> u) -> BigEndianDeserializer μ α -> [u]
forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> BigEndianDeserializer μ α
-> r
forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> BigEndianDeserializer μ α
-> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> BigEndianDeserializer μ α -> m (BigEndianDeserializer μ α)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> BigEndianDeserializer μ α -> m (BigEndianDeserializer μ α)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (BigEndianDeserializer μ α)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> BigEndianDeserializer μ α
-> c (BigEndianDeserializer μ α)
forall (μ :: * -> *) α.
(Typeable μ, Typeable α, Data (μ α)) =>
Typeable (BigEndianDeserializer μ α)
forall (μ :: * -> *) α.
(Typeable μ, Typeable α, Data (μ α)) =>
BigEndianDeserializer μ α -> DataType
forall (μ :: * -> *) α.
(Typeable μ, Typeable α, Data (μ α)) =>
BigEndianDeserializer μ α -> Constr
forall (μ :: * -> *) α.
(Typeable μ, Typeable α, Data (μ α)) =>
(forall b. Data b => b -> b)
-> BigEndianDeserializer μ α -> BigEndianDeserializer μ α
forall (μ :: * -> *) α u.
(Typeable μ, Typeable α, Data (μ α)) =>
Int
-> (forall d. Data d => d -> u) -> BigEndianDeserializer μ α -> u
forall (μ :: * -> *) α u.
(Typeable μ, Typeable α, Data (μ α)) =>
(forall d. Data d => d -> u) -> BigEndianDeserializer μ α -> [u]
forall (μ :: * -> *) α r r'.
(Typeable μ, Typeable α, Data (μ α)) =>
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> BigEndianDeserializer μ α
-> r
forall (μ :: * -> *) α r r'.
(Typeable μ, Typeable α, Data (μ α)) =>
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> BigEndianDeserializer μ α
-> r
forall (μ :: * -> *) α (m :: * -> *).
(Typeable μ, Typeable α, Data (μ α), Monad m) =>
(forall d. Data d => d -> m d)
-> BigEndianDeserializer μ α -> m (BigEndianDeserializer μ α)
forall (μ :: * -> *) α (m :: * -> *).
(Typeable μ, Typeable α, Data (μ α), MonadPlus m) =>
(forall d. Data d => d -> m d)
-> BigEndianDeserializer μ α -> m (BigEndianDeserializer μ α)
forall (μ :: * -> *) α (c :: * -> *).
(Typeable μ, Typeable α, Data (μ α)) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (BigEndianDeserializer μ α)
forall (μ :: * -> *) α (c :: * -> *).
(Typeable μ, Typeable α, Data (μ α)) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> BigEndianDeserializer μ α
-> c (BigEndianDeserializer μ α)
forall (μ :: * -> *) α (t :: * -> *) (c :: * -> *).
(Typeable μ, Typeable α, Data (μ α), Typeable t) =>
(forall d. Data d => c (t d))
-> Maybe (c (BigEndianDeserializer μ α))
forall (μ :: * -> *) α (t :: * -> * -> *) (c :: * -> *).
(Typeable μ, Typeable α, Data (μ α), Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (BigEndianDeserializer μ α))
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c (BigEndianDeserializer μ α))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (BigEndianDeserializer μ α))
$cBigEndianDeserializer :: Constr
$tBigEndianDeserializer :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> BigEndianDeserializer μ α -> m (BigEndianDeserializer μ α)
$cgmapMo :: forall (μ :: * -> *) α (m :: * -> *).
(Typeable μ, Typeable α, Data (μ α), MonadPlus m) =>
(forall d. Data d => d -> m d)
-> BigEndianDeserializer μ α -> m (BigEndianDeserializer μ α)
gmapMp :: (forall d. Data d => d -> m d)
-> BigEndianDeserializer μ α -> m (BigEndianDeserializer μ α)
$cgmapMp :: forall (μ :: * -> *) α (m :: * -> *).
(Typeable μ, Typeable α, Data (μ α), MonadPlus m) =>
(forall d. Data d => d -> m d)
-> BigEndianDeserializer μ α -> m (BigEndianDeserializer μ α)
gmapM :: (forall d. Data d => d -> m d)
-> BigEndianDeserializer μ α -> m (BigEndianDeserializer μ α)
$cgmapM :: forall (μ :: * -> *) α (m :: * -> *).
(Typeable μ, Typeable α, Data (μ α), Monad m) =>
(forall d. Data d => d -> m d)
-> BigEndianDeserializer μ α -> m (BigEndianDeserializer μ α)
gmapQi :: Int
-> (forall d. Data d => d -> u) -> BigEndianDeserializer μ α -> u
$cgmapQi :: forall (μ :: * -> *) α u.
(Typeable μ, Typeable α, Data (μ α)) =>
Int
-> (forall d. Data d => d -> u) -> BigEndianDeserializer μ α -> u
gmapQ :: (forall d. Data d => d -> u) -> BigEndianDeserializer μ α -> [u]
$cgmapQ :: forall (μ :: * -> *) α u.
(Typeable μ, Typeable α, Data (μ α)) =>
(forall d. Data d => d -> u) -> BigEndianDeserializer μ α -> [u]
gmapQr :: (r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> BigEndianDeserializer μ α
-> r
$cgmapQr :: forall (μ :: * -> *) α r r'.
(Typeable μ, Typeable α, Data (μ α)) =>
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> BigEndianDeserializer μ α
-> r
gmapQl :: (r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> BigEndianDeserializer μ α
-> r
$cgmapQl :: forall (μ :: * -> *) α r r'.
(Typeable μ, Typeable α, Data (μ α)) =>
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> BigEndianDeserializer μ α
-> r
gmapT :: (forall b. Data b => b -> b)
-> BigEndianDeserializer μ α -> BigEndianDeserializer μ α
$cgmapT :: forall (μ :: * -> *) α.
(Typeable μ, Typeable α, Data (μ α)) =>
(forall b. Data b => b -> b)
-> BigEndianDeserializer μ α -> BigEndianDeserializer μ α
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (BigEndianDeserializer μ α))
$cdataCast2 :: forall (μ :: * -> *) α (t :: * -> * -> *) (c :: * -> *).
(Typeable μ, Typeable α, Data (μ α), Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (BigEndianDeserializer μ α))
dataCast1 :: (forall d. Data d => c (t d))
-> Maybe (c (BigEndianDeserializer μ α))
$cdataCast1 :: forall (μ :: * -> *) α (t :: * -> *) (c :: * -> *).
(Typeable μ, Typeable α, Data (μ α), Typeable t) =>
(forall d. Data d => c (t d))
-> Maybe (c (BigEndianDeserializer μ α))
dataTypeOf :: BigEndianDeserializer μ α -> DataType
$cdataTypeOf :: forall (μ :: * -> *) α.
(Typeable μ, Typeable α, Data (μ α)) =>
BigEndianDeserializer μ α -> DataType
toConstr :: BigEndianDeserializer μ α -> Constr
$ctoConstr :: forall (μ :: * -> *) α.
(Typeable μ, Typeable α, Data (μ α)) =>
BigEndianDeserializer μ α -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (BigEndianDeserializer μ α)
$cgunfold :: forall (μ :: * -> *) α (c :: * -> *).
(Typeable μ, Typeable α, Data (μ α)) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (BigEndianDeserializer μ α)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> BigEndianDeserializer μ α
-> c (BigEndianDeserializer μ α)
$cgfoldl :: forall (μ :: * -> *) α (c :: * -> *).
(Typeable μ, Typeable α, Data (μ α)) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> BigEndianDeserializer μ α
-> c (BigEndianDeserializer μ α)
$cp1Data :: forall (μ :: * -> *) α.
(Typeable μ, Typeable α, Data (μ α)) =>
Typeable (BigEndianDeserializer μ α)
Data, (forall x.
BigEndianDeserializer μ α -> Rep (BigEndianDeserializer μ α) x)
-> (forall x.
Rep (BigEndianDeserializer μ α) x -> BigEndianDeserializer μ α)
-> Generic (BigEndianDeserializer μ α)
forall x.
Rep (BigEndianDeserializer μ α) x -> BigEndianDeserializer μ α
forall x.
BigEndianDeserializer μ α -> Rep (BigEndianDeserializer μ α) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (μ :: * -> *) α x.
Rep (BigEndianDeserializer μ α) x -> BigEndianDeserializer μ α
forall (μ :: * -> *) α x.
BigEndianDeserializer μ α -> Rep (BigEndianDeserializer μ α) x
$cto :: forall (μ :: * -> *) α x.
Rep (BigEndianDeserializer μ α) x -> BigEndianDeserializer μ α
$cfrom :: forall (μ :: * -> *) α x.
BigEndianDeserializer μ α -> Rep (BigEndianDeserializer μ α) x
Generic, a -> BigEndianDeserializer μ b -> BigEndianDeserializer μ a
(a -> b) -> BigEndianDeserializer μ a -> BigEndianDeserializer μ b
(forall a b.
(a -> b) -> BigEndianDeserializer μ a -> BigEndianDeserializer μ b)
-> (forall a b.
a -> BigEndianDeserializer μ b -> BigEndianDeserializer μ a)
-> Functor (BigEndianDeserializer μ)
forall a b.
a -> BigEndianDeserializer μ b -> BigEndianDeserializer μ a
forall a b.
(a -> b) -> BigEndianDeserializer μ a -> BigEndianDeserializer μ b
forall (μ :: * -> *) a b.
Functor μ =>
a -> BigEndianDeserializer μ b -> BigEndianDeserializer μ a
forall (μ :: * -> *) a b.
Functor μ =>
(a -> b) -> BigEndianDeserializer μ a -> BigEndianDeserializer μ b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> BigEndianDeserializer μ b -> BigEndianDeserializer μ a
$c<$ :: forall (μ :: * -> *) a b.
Functor μ =>
a -> BigEndianDeserializer μ b -> BigEndianDeserializer μ a
fmap :: (a -> b) -> BigEndianDeserializer μ a -> BigEndianDeserializer μ b
$cfmap :: forall (μ :: * -> *) a b.
Functor μ =>
(a -> b) -> BigEndianDeserializer μ a -> BigEndianDeserializer μ b
Functor, Functor (BigEndianDeserializer μ)
a -> BigEndianDeserializer μ a
Functor (BigEndianDeserializer μ)
-> (forall a. a -> BigEndianDeserializer μ a)
-> (forall a b.
BigEndianDeserializer μ (a -> b)
-> BigEndianDeserializer μ a -> BigEndianDeserializer μ b)
-> (forall a b c.
(a -> b -> c)
-> BigEndianDeserializer μ a
-> BigEndianDeserializer μ b
-> BigEndianDeserializer μ c)
-> (forall a b.
BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ b)
-> (forall a b.
BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ a)
-> Applicative (BigEndianDeserializer μ)
BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ b
BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ a
BigEndianDeserializer μ (a -> b)
-> BigEndianDeserializer μ a -> BigEndianDeserializer μ b
(a -> b -> c)
-> BigEndianDeserializer μ a
-> BigEndianDeserializer μ b
-> BigEndianDeserializer μ c
forall a. a -> BigEndianDeserializer μ a
forall a b.
BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ a
forall a b.
BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ b
forall a b.
BigEndianDeserializer μ (a -> b)
-> BigEndianDeserializer μ a -> BigEndianDeserializer μ b
forall a b c.
(a -> b -> c)
-> BigEndianDeserializer μ a
-> BigEndianDeserializer μ b
-> BigEndianDeserializer μ c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
forall (μ :: * -> *).
Applicative μ =>
Functor (BigEndianDeserializer μ)
forall (μ :: * -> *) a.
Applicative μ =>
a -> BigEndianDeserializer μ a
forall (μ :: * -> *) a b.
Applicative μ =>
BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ a
forall (μ :: * -> *) a b.
Applicative μ =>
BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ b
forall (μ :: * -> *) a b.
Applicative μ =>
BigEndianDeserializer μ (a -> b)
-> BigEndianDeserializer μ a -> BigEndianDeserializer μ b
forall (μ :: * -> *) a b c.
Applicative μ =>
(a -> b -> c)
-> BigEndianDeserializer μ a
-> BigEndianDeserializer μ b
-> BigEndianDeserializer μ c
<* :: BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ a
$c<* :: forall (μ :: * -> *) a b.
Applicative μ =>
BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ a
*> :: BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ b
$c*> :: forall (μ :: * -> *) a b.
Applicative μ =>
BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ b
liftA2 :: (a -> b -> c)
-> BigEndianDeserializer μ a
-> BigEndianDeserializer μ b
-> BigEndianDeserializer μ c
$cliftA2 :: forall (μ :: * -> *) a b c.
Applicative μ =>
(a -> b -> c)
-> BigEndianDeserializer μ a
-> BigEndianDeserializer μ b
-> BigEndianDeserializer μ c
<*> :: BigEndianDeserializer μ (a -> b)
-> BigEndianDeserializer μ a -> BigEndianDeserializer μ b
$c<*> :: forall (μ :: * -> *) a b.
Applicative μ =>
BigEndianDeserializer μ (a -> b)
-> BigEndianDeserializer μ a -> BigEndianDeserializer μ b
pure :: a -> BigEndianDeserializer μ a
$cpure :: forall (μ :: * -> *) a.
Applicative μ =>
a -> BigEndianDeserializer μ a
$cp1Applicative :: forall (μ :: * -> *).
Applicative μ =>
Functor (BigEndianDeserializer μ)
Applicative,
Applicative (BigEndianDeserializer μ)
BigEndianDeserializer μ a
Applicative (BigEndianDeserializer μ)
-> (forall a. BigEndianDeserializer μ a)
-> (forall a.
BigEndianDeserializer μ a
-> BigEndianDeserializer μ a -> BigEndianDeserializer μ a)
-> (forall a.
BigEndianDeserializer μ a -> BigEndianDeserializer μ [a])
-> (forall a.
BigEndianDeserializer μ a -> BigEndianDeserializer μ [a])
-> Alternative (BigEndianDeserializer μ)
BigEndianDeserializer μ a
-> BigEndianDeserializer μ a -> BigEndianDeserializer μ a
BigEndianDeserializer μ a -> BigEndianDeserializer μ [a]
BigEndianDeserializer μ a -> BigEndianDeserializer μ [a]
forall a. BigEndianDeserializer μ a
forall a. BigEndianDeserializer μ a -> BigEndianDeserializer μ [a]
forall a.
BigEndianDeserializer μ a
-> BigEndianDeserializer μ a -> BigEndianDeserializer μ a
forall (f :: * -> *).
Applicative f
-> (forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
forall (μ :: * -> *).
Alternative μ =>
Applicative (BigEndianDeserializer μ)
forall (μ :: * -> *) a. Alternative μ => BigEndianDeserializer μ a
forall (μ :: * -> *) a.
Alternative μ =>
BigEndianDeserializer μ a -> BigEndianDeserializer μ [a]
forall (μ :: * -> *) a.
Alternative μ =>
BigEndianDeserializer μ a
-> BigEndianDeserializer μ a -> BigEndianDeserializer μ a
many :: BigEndianDeserializer μ a -> BigEndianDeserializer μ [a]
$cmany :: forall (μ :: * -> *) a.
Alternative μ =>
BigEndianDeserializer μ a -> BigEndianDeserializer μ [a]
some :: BigEndianDeserializer μ a -> BigEndianDeserializer μ [a]
$csome :: forall (μ :: * -> *) a.
Alternative μ =>
BigEndianDeserializer μ a -> BigEndianDeserializer μ [a]
<|> :: BigEndianDeserializer μ a
-> BigEndianDeserializer μ a -> BigEndianDeserializer μ a
$c<|> :: forall (μ :: * -> *) a.
Alternative μ =>
BigEndianDeserializer μ a
-> BigEndianDeserializer μ a -> BigEndianDeserializer μ a
empty :: BigEndianDeserializer μ a
$cempty :: forall (μ :: * -> *) a. Alternative μ => BigEndianDeserializer μ a
$cp1Alternative :: forall (μ :: * -> *).
Alternative μ =>
Applicative (BigEndianDeserializer μ)
Alternative, Applicative (BigEndianDeserializer μ)
a -> BigEndianDeserializer μ a
Applicative (BigEndianDeserializer μ)
-> (forall a b.
BigEndianDeserializer μ a
-> (a -> BigEndianDeserializer μ b) -> BigEndianDeserializer μ b)
-> (forall a b.
BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ b)
-> (forall a. a -> BigEndianDeserializer μ a)
-> Monad (BigEndianDeserializer μ)
BigEndianDeserializer μ a
-> (a -> BigEndianDeserializer μ b) -> BigEndianDeserializer μ b
BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ b
forall a. a -> BigEndianDeserializer μ a
forall a b.
BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ b
forall a b.
BigEndianDeserializer μ a
-> (a -> BigEndianDeserializer μ b) -> BigEndianDeserializer μ b
forall (μ :: * -> *).
Monad μ =>
Applicative (BigEndianDeserializer μ)
forall (μ :: * -> *) a. Monad μ => a -> BigEndianDeserializer μ a
forall (μ :: * -> *) a b.
Monad μ =>
BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ b
forall (μ :: * -> *) a b.
Monad μ =>
BigEndianDeserializer μ a
-> (a -> BigEndianDeserializer μ b) -> BigEndianDeserializer μ b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> BigEndianDeserializer μ a
$creturn :: forall (μ :: * -> *) a. Monad μ => a -> BigEndianDeserializer μ a
>> :: BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ b
$c>> :: forall (μ :: * -> *) a b.
Monad μ =>
BigEndianDeserializer μ a
-> BigEndianDeserializer μ b -> BigEndianDeserializer μ b
>>= :: BigEndianDeserializer μ a
-> (a -> BigEndianDeserializer μ b) -> BigEndianDeserializer μ b
$c>>= :: forall (μ :: * -> *) a b.
Monad μ =>
BigEndianDeserializer μ a
-> (a -> BigEndianDeserializer μ b) -> BigEndianDeserializer μ b
$cp1Monad :: forall (μ :: * -> *).
Monad μ =>
Applicative (BigEndianDeserializer μ)
Monad, Alternative (BigEndianDeserializer μ)
BigEndianDeserializer μ ()
String -> BigEndianDeserializer μ a
Alternative (BigEndianDeserializer μ)
-> (forall a.
BigEndianDeserializer μ a -> BigEndianDeserializer μ a)
-> (forall a.
BigEndianDeserializer μ a -> String -> BigEndianDeserializer μ a)
-> (forall a.
BigEndianDeserializer μ a -> BigEndianDeserializer μ ())
-> (forall a.
BigEndianDeserializer μ a -> BigEndianDeserializer μ ())
-> (forall a. String -> BigEndianDeserializer μ a)
-> BigEndianDeserializer μ ()
-> (forall a.
Show a =>
BigEndianDeserializer μ a -> BigEndianDeserializer μ ())
-> Parsing (BigEndianDeserializer μ)
BigEndianDeserializer μ a -> BigEndianDeserializer μ a
BigEndianDeserializer μ a -> String -> BigEndianDeserializer μ a
BigEndianDeserializer μ a -> BigEndianDeserializer μ ()
BigEndianDeserializer μ a -> BigEndianDeserializer μ ()
BigEndianDeserializer μ a -> BigEndianDeserializer μ ()
forall a.
Show a =>
BigEndianDeserializer μ a -> BigEndianDeserializer μ ()
forall a. String -> BigEndianDeserializer μ a
forall a. BigEndianDeserializer μ a -> BigEndianDeserializer μ a
forall a. BigEndianDeserializer μ a -> BigEndianDeserializer μ ()
forall a.
BigEndianDeserializer μ a -> String -> BigEndianDeserializer μ a
forall (m :: * -> *).
Alternative m
-> (forall a. m a -> m a)
-> (forall a. m a -> String -> m a)
-> (forall a. m a -> m ())
-> (forall a. m a -> m ())
-> (forall a. String -> m a)
-> m ()
-> (forall a. Show a => m a -> m ())
-> Parsing m
forall (μ :: * -> *).
Parsing μ =>
Alternative (BigEndianDeserializer μ)
forall (μ :: * -> *). Parsing μ => BigEndianDeserializer μ ()
forall (μ :: * -> *) a.
(Parsing μ, Show a) =>
BigEndianDeserializer μ a -> BigEndianDeserializer μ ()
forall (μ :: * -> *) a.
Parsing μ =>
String -> BigEndianDeserializer μ a
forall (μ :: * -> *) a.
Parsing μ =>
BigEndianDeserializer μ a -> BigEndianDeserializer μ a
forall (μ :: * -> *) a.
Parsing μ =>
BigEndianDeserializer μ a -> BigEndianDeserializer μ ()
forall (μ :: * -> *) a.
Parsing μ =>
BigEndianDeserializer μ a -> String -> BigEndianDeserializer μ a
notFollowedBy :: BigEndianDeserializer μ a -> BigEndianDeserializer μ ()
$cnotFollowedBy :: forall (μ :: * -> *) a.
(Parsing μ, Show a) =>
BigEndianDeserializer μ a -> BigEndianDeserializer μ ()
eof :: BigEndianDeserializer μ ()
$ceof :: forall (μ :: * -> *). Parsing μ => BigEndianDeserializer μ ()
unexpected :: String -> BigEndianDeserializer μ a
$cunexpected :: forall (μ :: * -> *) a.
Parsing μ =>
String -> BigEndianDeserializer μ a
skipSome :: BigEndianDeserializer μ a -> BigEndianDeserializer μ ()
$cskipSome :: forall (μ :: * -> *) a.
Parsing μ =>
BigEndianDeserializer μ a -> BigEndianDeserializer μ ()
skipMany :: BigEndianDeserializer μ a -> BigEndianDeserializer μ ()
$cskipMany :: forall (μ :: * -> *) a.
Parsing μ =>
BigEndianDeserializer μ a -> BigEndianDeserializer μ ()
<?> :: BigEndianDeserializer μ a -> String -> BigEndianDeserializer μ a
$c<?> :: forall (μ :: * -> *) a.
Parsing μ =>
BigEndianDeserializer μ a -> String -> BigEndianDeserializer μ a
try :: BigEndianDeserializer μ a -> BigEndianDeserializer μ a
$ctry :: forall (μ :: * -> *) a.
Parsing μ =>
BigEndianDeserializer μ a -> BigEndianDeserializer μ a
$cp1Parsing :: forall (μ :: * -> *).
Parsing μ =>
Alternative (BigEndianDeserializer μ)
Parsing, Parsing (BigEndianDeserializer μ)
Parsing (BigEndianDeserializer μ)
-> (forall a.
BigEndianDeserializer μ a -> BigEndianDeserializer μ a)
-> LookAheadParsing (BigEndianDeserializer μ)
BigEndianDeserializer μ a -> BigEndianDeserializer μ a
forall a. BigEndianDeserializer μ a -> BigEndianDeserializer μ a
forall (μ :: * -> *).
LookAheadParsing μ =>
Parsing (BigEndianDeserializer μ)
forall (μ :: * -> *) a.
LookAheadParsing μ =>
BigEndianDeserializer μ a -> BigEndianDeserializer μ a
forall (m :: * -> *).
Parsing m -> (forall a. m a -> m a) -> LookAheadParsing m
lookAhead :: BigEndianDeserializer μ a -> BigEndianDeserializer μ a
$clookAhead :: forall (μ :: * -> *) a.
LookAheadParsing μ =>
BigEndianDeserializer μ a -> BigEndianDeserializer μ a
$cp1LookAheadParsing :: forall (μ :: * -> *).
LookAheadParsing μ =>
Parsing (BigEndianDeserializer μ)
LookAheadParsing)
instance Deserializer μ ⇒ Deserializer (BigEndianDeserializer μ) where
endian :: Proxy (BigEndianDeserializer μ) -> Endian
endian Proxy (BigEndianDeserializer μ)
_ = Endian
BigEndian
{-# INLINE endian #-}
word8 :: BigEndianDeserializer μ Word8
word8 = μ Word8 -> BigEndianDeserializer μ Word8
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer μ Word8
forall (μ :: * -> *). Deserializer μ => μ Word8
word8
{-# INLINE word8 #-}
word16 :: BigEndianDeserializer μ Word16
word16 = μ Word16 -> BigEndianDeserializer μ Word16
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer μ Word16
forall (μ :: * -> *). Deserializer μ => μ Word16
word16B
{-# INLINE word16 #-}
word32 :: BigEndianDeserializer μ Word32
word32 = μ Word32 -> BigEndianDeserializer μ Word32
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer μ Word32
forall (μ :: * -> *). Deserializer μ => μ Word32
word32B
{-# INLINE word32 #-}
word64 :: BigEndianDeserializer μ Word64
word64 = μ Word64 -> BigEndianDeserializer μ Word64
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer μ Word64
forall (μ :: * -> *). Deserializer μ => μ Word64
word64B
{-# INLINE word64 #-}
word16L :: BigEndianDeserializer μ Word16
word16L = μ Word16 -> BigEndianDeserializer μ Word16
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer μ Word16
forall (μ :: * -> *). Deserializer μ => μ Word16
word16L
{-# INLINE word16L #-}
word16B :: BigEndianDeserializer μ Word16
word16B = μ Word16 -> BigEndianDeserializer μ Word16
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer μ Word16
forall (μ :: * -> *). Deserializer μ => μ Word16
word16B
{-# INLINE word16B #-}
word32L :: BigEndianDeserializer μ Word32
word32L = μ Word32 -> BigEndianDeserializer μ Word32
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer μ Word32
forall (μ :: * -> *). Deserializer μ => μ Word32
word32L
{-# INLINE word32L #-}
word32B :: BigEndianDeserializer μ Word32
word32B = μ Word32 -> BigEndianDeserializer μ Word32
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer μ Word32
forall (μ :: * -> *). Deserializer μ => μ Word32
word32B
{-# INLINE word32B #-}
word64L :: BigEndianDeserializer μ Word64
word64L = μ Word64 -> BigEndianDeserializer μ Word64
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer μ Word64
forall (μ :: * -> *). Deserializer μ => μ Word64
word64L
{-# INLINE word64L #-}
word64B :: BigEndianDeserializer μ Word64
word64B = μ Word64 -> BigEndianDeserializer μ Word64
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer μ Word64
forall (μ :: * -> *). Deserializer μ => μ Word64
word64B
{-# INLINE word64B #-}
satisfy :: (Word8 -> Bool) -> BigEndianDeserializer μ Word8
satisfy = μ Word8 -> BigEndianDeserializer μ Word8
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer (μ Word8 -> BigEndianDeserializer μ Word8)
-> ((Word8 -> Bool) -> μ Word8)
-> (Word8 -> Bool)
-> BigEndianDeserializer μ Word8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word8 -> Bool) -> μ Word8
forall (μ :: * -> *). Deserializer μ => (Word8 -> Bool) -> μ Word8
satisfy
{-# INLINE satisfy #-}
byte :: Word8 -> BigEndianDeserializer μ Word8
byte = μ Word8 -> BigEndianDeserializer μ Word8
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer (μ Word8 -> BigEndianDeserializer μ Word8)
-> (Word8 -> μ Word8) -> Word8 -> BigEndianDeserializer μ Word8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> μ Word8
forall (μ :: * -> *). Deserializer μ => Word8 -> μ Word8
byte
{-# INLINE byte #-}
notByte :: Word8 -> BigEndianDeserializer μ Word8
notByte = μ Word8 -> BigEndianDeserializer μ Word8
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer (μ Word8 -> BigEndianDeserializer μ Word8)
-> (Word8 -> μ Word8) -> Word8 -> BigEndianDeserializer μ Word8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> μ Word8
forall (μ :: * -> *). Deserializer μ => Word8 -> μ Word8
notByte
{-# INLINE notByte #-}
bytes :: ByteString -> BigEndianDeserializer μ ByteString
bytes = μ ByteString -> BigEndianDeserializer μ ByteString
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer (μ ByteString -> BigEndianDeserializer μ ByteString)
-> (ByteString -> μ ByteString)
-> ByteString
-> BigEndianDeserializer μ ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> μ ByteString
forall (μ :: * -> *). Deserializer μ => ByteString -> μ ByteString
bytes
{-# INLINE bytes #-}
skip :: Int -> BigEndianDeserializer μ ()
skip = μ () -> BigEndianDeserializer μ ()
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer (μ () -> BigEndianDeserializer μ ())
-> (Int -> μ ()) -> Int -> BigEndianDeserializer μ ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> μ ()
forall (μ :: * -> *). Deserializer μ => Int -> μ ()
skip
{-# INLINE skip #-}
ensure :: Int -> BigEndianDeserializer μ ByteString
ensure = μ ByteString -> BigEndianDeserializer μ ByteString
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer (μ ByteString -> BigEndianDeserializer μ ByteString)
-> (Int -> μ ByteString)
-> Int
-> BigEndianDeserializer μ ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> μ ByteString
forall (μ :: * -> *). Deserializer μ => Int -> μ ByteString
ensure
{-# INLINE ensure #-}
ensure_ :: Int -> BigEndianDeserializer μ ()
ensure_ = μ () -> BigEndianDeserializer μ ()
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer (μ () -> BigEndianDeserializer μ ())
-> (Int -> μ ()) -> Int -> BigEndianDeserializer μ ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> μ ()
forall (μ :: * -> *). Deserializer μ => Int -> μ ()
ensure_
{-# INLINE ensure_ #-}
take :: Int -> BigEndianDeserializer μ ByteString
take = μ ByteString -> BigEndianDeserializer μ ByteString
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer (μ ByteString -> BigEndianDeserializer μ ByteString)
-> (Int -> μ ByteString)
-> Int
-> BigEndianDeserializer μ ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> μ ByteString
forall (μ :: * -> *). Deserializer μ => Int -> μ ByteString
take
{-# INLINE take #-}
chunk :: BigEndianDeserializer μ ByteString
chunk = μ ByteString -> BigEndianDeserializer μ ByteString
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer μ ByteString
forall (μ :: * -> *). Deserializer μ => μ ByteString
chunk
{-# INLINE chunk #-}
isolate :: Int -> BigEndianDeserializer μ α -> BigEndianDeserializer μ α
isolate Int
n = μ α -> BigEndianDeserializer μ α
forall (μ :: * -> *) α. μ α -> BigEndianDeserializer μ α
BigEndianDeserializer (μ α -> BigEndianDeserializer μ α)
-> (BigEndianDeserializer μ α -> μ α)
-> BigEndianDeserializer μ α
-> BigEndianDeserializer μ α
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> μ α -> μ α
forall (μ :: * -> *) α. Deserializer μ => Int -> μ α -> μ α
isolate Int
n (μ α -> μ α)
-> (BigEndianDeserializer μ α -> μ α)
-> BigEndianDeserializer μ α
-> μ α
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BigEndianDeserializer μ α -> μ α
forall (μ :: * -> *) α. BigEndianDeserializer μ α -> μ α
deserializeB
{-# INLINE isolate #-}
deserializeIn ∷ Deserializer μ
⇒ Endian → (∀ μ' . (Deserializer μ') ⇒ μ' α) → μ α
deserializeIn :: Endian -> (forall (μ' :: * -> *). Deserializer μ' => μ' α) -> μ α
deserializeIn Endian
LittleEndian forall (μ' :: * -> *). Deserializer μ' => μ' α
d = LittleEndianDeserializer μ α -> μ α
forall (μ :: * -> *) α. LittleEndianDeserializer μ α -> μ α
deserializeL LittleEndianDeserializer μ α
forall (μ' :: * -> *). Deserializer μ' => μ' α
d
deserializeIn Endian
BigEndian forall (μ' :: * -> *). Deserializer μ' => μ' α
d = BigEndianDeserializer μ α -> μ α
forall (μ :: * -> *) α. BigEndianDeserializer μ α -> μ α
deserializeB BigEndianDeserializer μ α
forall (μ' :: * -> *). Deserializer μ' => μ' α
d
{-# INLINE deserializeIn #-}
deserializeH ∷ Deserializer μ ⇒ (∀ μ' . (Deserializer μ') ⇒ μ' α) → μ α
#ifdef WORDS_BIGENDIAN
deserializeH d = deserializeB d
#else
deserializeH :: (forall (μ' :: * -> *). Deserializer μ' => μ' α) -> μ α
deserializeH forall (μ' :: * -> *). Deserializer μ' => μ' α
d = LittleEndianDeserializer μ α -> μ α
forall (μ :: * -> *) α. LittleEndianDeserializer μ α -> μ α
deserializeL LittleEndianDeserializer μ α
forall (μ' :: * -> *). Deserializer μ' => μ' α
d
#endif
{-# INLINE deserializeH #-}
data Deserialized α = Deserialized α
| Malformed [String] String
isDeserialized ∷ Deserialized α → Bool
isDeserialized :: Deserialized α -> Bool
isDeserialized (Deserialized α
_) = Bool
True
isDeserialized (Malformed [String]
_ String
_) = Bool
False
isMalformed ∷ Deserialized α → Bool
isMalformed :: Deserialized α -> Bool
isMalformed (Deserialized α
_) = Bool
False
isMalformed (Malformed [String]
_ String
_) = Bool
True
maybeDeserialized ∷ Deserialized α → Maybe α
maybeDeserialized :: Deserialized α -> Maybe α
maybeDeserialized (Deserialized α
a) = α -> Maybe α
forall a. a -> Maybe a
Just α
a
maybeDeserialized (Malformed [String]
_ String
_) = Maybe α
forall a. Maybe a
Nothing
defaultDeserializer ∷ (∀ μ . Deserializer μ ⇒ μ α) → LBS.ByteString
→ Deserialized α
defaultDeserializer :: (forall (μ :: * -> *). Deserializer μ => μ α)
-> ByteString -> Deserialized α
defaultDeserializer forall (μ :: * -> *). Deserializer μ => μ α
m ByteString
i = case Get α
-> ByteString
-> Either (ByteString, Int64, String) (ByteString, Int64, α)
forall a.
Get a
-> ByteString
-> Either (ByteString, Int64, String) (ByteString, Int64, a)
B.runGetOrFail (BinaryDeserializer α -> Get α
forall α. BinaryDeserializer α -> Get α
binaryDeserializer BinaryDeserializer α
forall (μ :: * -> *). Deserializer μ => μ α
m) ByteString
i of
Left (ByteString
_, Int64
_, String
e) → case String -> String -> [String]
forall a. Eq a => [a] -> [a] -> [[a]]
splitOn String
"\n" String
e of
[] → [String] -> String -> Deserialized α
forall α. [String] -> String -> Deserialized α
Malformed [] String
e
[String
_] → [String] -> String -> Deserialized α
forall α. [String] -> String -> Deserialized α
Malformed [] String
e
[String]
es → [String] -> String -> Deserialized α
forall α. [String] -> String -> Deserialized α
Malformed ([String] -> [String]
forall a. [a] -> [a]
init [String]
es) ([String] -> String
forall a. [a] -> a
last [String]
es)
Right (ByteString
_, Int64
_, α
a) →
α -> Deserialized α
forall α. α -> Deserialized α
Deserialized α
a
class Deserializable α where
get ∷ Deserializer μ ⇒ μ α
instance Deserializable Bool where
get :: μ Bool
get = do Word8
w ← μ Word8
forall (μ :: * -> *). Deserializer μ => μ Word8
word8
case Word8
w of
Word8
0 → Bool -> μ Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
Word8
1 → Bool -> μ Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
Word8
_ → String -> μ Bool
forall (m :: * -> *) a. Parsing m => String -> m a
unexpected (Word8 -> String
forall a. Show a => a -> String
show Word8
w)
instance Deserializable Word8 where
get :: μ Word8
get = μ Word8
forall (μ :: * -> *). Deserializer μ => μ Word8
word8
{-# INLINE get #-}
instance Deserializable Word16 where
get :: μ Word16
get = μ Word16
forall (μ :: * -> *). Deserializer μ => μ Word16
word16
{-# INLINE get #-}
instance Deserializable Word32 where
get :: μ Word32
get = μ Word32
forall (μ :: * -> *). Deserializer μ => μ Word32
word32
{-# INLINE get #-}
instance Deserializable Word64 where
get :: μ Word64
get = μ Word64
forall (μ :: * -> *). Deserializer μ => μ Word64
word64
{-# INLINE get #-}
instance Deserializable Word where
get :: μ Word
get = μ Word
forall (μ :: * -> *). Deserializer μ => μ Word
word
{-# INLINE get #-}
instance Deserializable Int8 where
get :: μ Int8
get = μ Int8
forall (μ :: * -> *). Deserializer μ => μ Int8
int8
{-# INLINE get #-}
instance Deserializable Int16 where
get :: μ Int16
get = μ Int16
forall (μ :: * -> *). Deserializer μ => μ Int16
int16
{-# INLINE get #-}
instance Deserializable Int32 where
get :: μ Int32
get = μ Int32
forall (μ :: * -> *). Deserializer μ => μ Int32
int32
{-# INLINE get #-}
instance Deserializable Int64 where
get :: μ Int64
get = μ Int64
forall (μ :: * -> *). Deserializer μ => μ Int64
int64
{-# INLINE get #-}
instance Deserializable Int where
get :: μ Int
get = μ Int
forall (μ :: * -> *). Deserializer μ => μ Int
int
{-# INLINE get #-}
instance (Deserializable α, Deserializable β) ⇒ Deserializable (α, β) where
get :: μ (α, β)
get = (,) (α -> β -> (α, β)) -> μ α -> μ (β -> (α, β))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ α
forall α (μ :: * -> *). (Deserializable α, Deserializer μ) => μ α
get μ (β -> (α, β)) -> μ β -> μ (α, β)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> μ β
forall α (μ :: * -> *). (Deserializable α, Deserializer μ) => μ α
get
{-# INLINE get #-}
instance Deserializable α ⇒ Deserializable (Maybe α) where
get :: μ (Maybe α)
get = do Word8
w ← μ Word8
forall (μ :: * -> *). Deserializer μ => μ Word8
word8
case Word8
w of
Word8
0 → Maybe α -> μ (Maybe α)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe α
forall a. Maybe a
Nothing
Word8
1 → α -> Maybe α
forall a. a -> Maybe a
Just (α -> Maybe α) -> μ α -> μ (Maybe α)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ α
forall α (μ :: * -> *). (Deserializable α, Deserializer μ) => μ α
get
Word8
_ → String -> μ (Maybe α)
forall (m :: * -> *) a. Parsing m => String -> m a
unexpected (Word8 -> String
forall a. Show a => a -> String
show Word8
w)
instance (Deserializable α, Deserializable β)
⇒ Deserializable (Either α β) where
get :: μ (Either α β)
get = do Word8
w ← μ Word8
forall (μ :: * -> *). Deserializer μ => μ Word8
word8
case Word8
w of
Word8
0 → α -> Either α β
forall a b. a -> Either a b
Left (α -> Either α β) -> μ α -> μ (Either α β)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ α
forall α (μ :: * -> *). (Deserializable α, Deserializer μ) => μ α
get
Word8
1 → β -> Either α β
forall a b. b -> Either a b
Right (β -> Either α β) -> μ β -> μ (Either α β)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ β
forall α (μ :: * -> *). (Deserializable α, Deserializer μ) => μ α
get
Word8
_ → String -> μ (Either α β)
forall (m :: * -> *) a. Parsing m => String -> m a
unexpected (Word8 -> String
forall a. Show a => a -> String
show Word8
w)
instance Deserializable BS.ByteString where
get :: μ ByteString
get = do Int
l ← μ Int
forall (μ :: * -> *). Deserializer μ => μ Int
int μ Int -> String -> μ Int
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"length"
Bool -> μ () -> μ ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Int
l Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
0) (μ () -> μ ()) -> μ () -> μ ()
forall a b. (a -> b) -> a -> b
$ String -> μ ()
forall (m :: * -> *) a. Parsing m => String -> m a
unexpected String
"negative length"
Int -> μ ByteString
forall (μ :: * -> *). Deserializer μ => Int -> μ ByteString
take Int
l μ ByteString -> String -> μ ByteString
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"contents"
{-# INLINABLE get #-}
instance Deserializable SBS.ShortByteString where
get :: μ ShortByteString
get = ByteString -> ShortByteString
SBS.toShort (ByteString -> ShortByteString)
-> μ ByteString -> μ ShortByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ ByteString
forall α (μ :: * -> *). (Deserializable α, Deserializer μ) => μ α
get
{-# INLINE get #-}
getIn ∷ (Deserializer μ, Deserializable α) ⇒ Endian → μ α
getIn :: Endian -> μ α
getIn Endian
e = Endian -> (forall (μ' :: * -> *). Deserializer μ' => μ' α) -> μ α
forall (μ :: * -> *) α.
Deserializer μ =>
Endian -> (forall (μ' :: * -> *). Deserializer μ' => μ' α) -> μ α
deserializeIn Endian
e forall α (μ :: * -> *). (Deserializable α, Deserializer μ) => μ α
forall (μ' :: * -> *). Deserializer μ' => μ' α
get
{-# INLINE getIn #-}
getL ∷ (Deserializer μ, Deserializable α) ⇒ μ α
getL :: μ α
getL = LittleEndianDeserializer μ α -> μ α
forall (μ :: * -> *) α. LittleEndianDeserializer μ α -> μ α
deserializeL LittleEndianDeserializer μ α
forall α (μ :: * -> *). (Deserializable α, Deserializer μ) => μ α
get
{-# INLINE getL #-}
getB ∷ (Deserializer μ, Deserializable α) ⇒ μ α
getB :: μ α
getB = BigEndianDeserializer μ α -> μ α
forall (μ :: * -> *) α. BigEndianDeserializer μ α -> μ α
deserializeB BigEndianDeserializer μ α
forall α (μ :: * -> *). (Deserializable α, Deserializer μ) => μ α
get
{-# INLINE getB #-}
getH ∷ (Deserializer μ, Deserializable α) ⇒ μ α
#ifdef WORDS_BIGENDIAN
getH = getB
#else
getH :: μ α
getH = μ α
forall (μ :: * -> *) α. (Deserializer μ, Deserializable α) => μ α
getL
#endif
{-# INLINE getH #-}
deserializeBytes ∷ Deserializable α ⇒ [Word8] → Deserialized α
deserializeBytes :: [Word8] -> Deserialized α
deserializeBytes = (forall (μ :: * -> *). Deserializer μ => μ α)
-> ByteString -> Deserialized α
forall α.
(forall (μ :: * -> *). Deserializer μ => μ α)
-> ByteString -> Deserialized α
defaultDeserializer forall α (μ :: * -> *). (Deserializable α, Deserializer μ) => μ α
forall (μ :: * -> *). Deserializer μ => μ α
get (ByteString -> Deserialized α)
-> ([Word8] -> ByteString) -> [Word8] -> Deserialized α
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Word8] -> ByteString
LBS.pack
{-# INLINE deserializeBytes #-}
deserializeBytesAs ∷ Deserializable α ⇒ p α → [Word8] → Deserialized α
deserializeBytesAs :: p α -> [Word8] -> Deserialized α
deserializeBytesAs p α
_ = [Word8] -> Deserialized α
forall α. Deserializable α => [Word8] -> Deserialized α
deserializeBytes
{-# INLINE deserializeBytesAs #-}
deserializeByteString ∷ Deserializable α
⇒ BS.ByteString → Deserialized α
deserializeByteString :: ByteString -> Deserialized α
deserializeByteString = (forall (μ :: * -> *). Deserializer μ => μ α)
-> ByteString -> Deserialized α
forall α.
(forall (μ :: * -> *). Deserializer μ => μ α)
-> ByteString -> Deserialized α
defaultDeserializer forall α (μ :: * -> *). (Deserializable α, Deserializer μ) => μ α
forall (μ :: * -> *). Deserializer μ => μ α
get (ByteString -> Deserialized α)
-> (ByteString -> ByteString) -> ByteString -> Deserialized α
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
LBS.fromStrict
{-# INLINE deserializeByteString #-}
deserializeByteStringAs ∷ Deserializable α
⇒ p α → BS.ByteString → Deserialized α
deserializeByteStringAs :: p α -> ByteString -> Deserialized α
deserializeByteStringAs p α
_ = ByteString -> Deserialized α
forall α. Deserializable α => ByteString -> Deserialized α
deserializeByteString
{-# INLINE deserializeByteStringAs #-}
deserializeLazyByteString ∷ Deserializable α
⇒ LBS.ByteString → Deserialized α
deserializeLazyByteString :: ByteString -> Deserialized α
deserializeLazyByteString = (forall (μ :: * -> *). Deserializer μ => μ α)
-> ByteString -> Deserialized α
forall α.
(forall (μ :: * -> *). Deserializer μ => μ α)
-> ByteString -> Deserialized α
defaultDeserializer forall α (μ :: * -> *). (Deserializable α, Deserializer μ) => μ α
forall (μ :: * -> *). Deserializer μ => μ α
get
{-# INLINE deserializeLazyByteString #-}
deserializeLazyByteStringAs ∷ Deserializable α
⇒ p α → LBS.ByteString → Deserialized α
deserializeLazyByteStringAs :: p α -> ByteString -> Deserialized α
deserializeLazyByteStringAs p α
_ = ByteString -> Deserialized α
forall α. Deserializable α => ByteString -> Deserialized α
deserializeLazyByteString
{-# INLINE deserializeLazyByteStringAs #-}
fromBytes ∷ Deserializable α ⇒ [Word8] → Maybe α
fromBytes :: [Word8] -> Maybe α
fromBytes = Deserialized α -> Maybe α
forall α. Deserialized α -> Maybe α
maybeDeserialized (Deserialized α -> Maybe α)
-> ([Word8] -> Deserialized α) -> [Word8] -> Maybe α
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Word8] -> Deserialized α
forall α. Deserializable α => [Word8] -> Deserialized α
deserializeBytes
{-# INLINE fromBytes #-}
fromBytesAs ∷ Deserializable α ⇒ p α → [Word8] → Maybe α
fromBytesAs :: p α -> [Word8] -> Maybe α
fromBytesAs p α
_ = [Word8] -> Maybe α
forall α. Deserializable α => [Word8] -> Maybe α
fromBytes
{-# INLINE fromBytesAs #-}
fromByteString ∷ Deserializable α ⇒ BS.ByteString → Maybe α
fromByteString :: ByteString -> Maybe α
fromByteString = Deserialized α -> Maybe α
forall α. Deserialized α -> Maybe α
maybeDeserialized (Deserialized α -> Maybe α)
-> (ByteString -> Deserialized α) -> ByteString -> Maybe α
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Deserialized α
forall α. Deserializable α => ByteString -> Deserialized α
deserializeByteString
{-# INLINE fromByteString #-}
fromByteStringAs ∷ Deserializable α ⇒ p α → BS.ByteString → Maybe α
fromByteStringAs :: p α -> ByteString -> Maybe α
fromByteStringAs p α
_ = ByteString -> Maybe α
forall α. Deserializable α => ByteString -> Maybe α
fromByteString
{-# INLINE fromByteStringAs #-}
fromLazyByteString ∷ Deserializable α ⇒ LBS.ByteString → Maybe α
fromLazyByteString :: ByteString -> Maybe α
fromLazyByteString = Deserialized α -> Maybe α
forall α. Deserialized α -> Maybe α
maybeDeserialized (Deserialized α -> Maybe α)
-> (ByteString -> Deserialized α) -> ByteString -> Maybe α
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Deserialized α
forall α. Deserializable α => ByteString -> Deserialized α
deserializeLazyByteString
{-# INLINE fromLazyByteString #-}
fromLazyByteStringAs ∷ Deserializable α ⇒ p α → LBS.ByteString → Maybe α
fromLazyByteStringAs :: p α -> ByteString -> Maybe α
fromLazyByteStringAs p α
_ = ByteString -> Maybe α
forall α. Deserializable α => ByteString -> Maybe α
fromLazyByteString
{-# INLINE fromLazyByteStringAs #-}
class RestDeserializable α where
getRest ∷ Deserializer μ ⇒ μ α
instance RestDeserializable BS.ByteString where
getRest :: μ ByteString
getRest = [ByteString] -> μ ByteString
forall (m :: * -> *).
Deserializer m =>
[ByteString] -> m ByteString
go []
where go :: [ByteString] -> m ByteString
go [ByteString]
acc = do ByteString
bs ← m ByteString
forall (μ :: * -> *). Deserializer μ => μ ByteString
chunk
if ByteString -> Bool
BS.null ByteString
bs then ByteString -> m ByteString
forall (m :: * -> *) a. Monad m => a -> m a
return (ByteString -> m ByteString) -> ByteString -> m ByteString
forall a b. (a -> b) -> a -> b
$ [ByteString] -> ByteString
BS.concat ([ByteString] -> ByteString) -> [ByteString] -> ByteString
forall a b. (a -> b) -> a -> b
$ [ByteString] -> [ByteString]
forall a. [a] -> [a]
reverse [ByteString]
acc
else [ByteString] -> m ByteString
go (ByteString
bs ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: [ByteString]
acc)
instance RestDeserializable SBS.ShortByteString where
getRest :: μ ShortByteString
getRest = ByteString -> ShortByteString
SBS.toShort (ByteString -> ShortByteString)
-> μ ByteString -> μ ShortByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ ByteString
forall α (μ :: * -> *).
(RestDeserializable α, Deserializer μ) =>
μ α
getRest
{-# INLINE getRest #-}
instance RestDeserializable LBS.ByteString where
getRest :: μ ByteString
getRest = [ByteString] -> μ ByteString
forall (m :: * -> *).
Deserializer m =>
[ByteString] -> m ByteString
go []
where go :: [ByteString] -> m ByteString
go [ByteString]
acc = do ByteString
bs ← m ByteString
forall (μ :: * -> *). Deserializer μ => μ ByteString
chunk
if ByteString -> Bool
BS.null ByteString
bs then ByteString -> m ByteString
forall (m :: * -> *) a. Monad m => a -> m a
return (ByteString -> m ByteString) -> ByteString -> m ByteString
forall a b. (a -> b) -> a -> b
$ [ByteString] -> ByteString
LBS.fromChunks ([ByteString] -> ByteString) -> [ByteString] -> ByteString
forall a b. (a -> b) -> a -> b
$ [ByteString] -> [ByteString]
forall a. [a] -> [a]
reverse [ByteString]
acc
else [ByteString] -> m ByteString
go (ByteString
bs ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: [ByteString]
acc)
instance RestDeserializable BB.Builder where
getRest :: μ Builder
getRest = ByteString -> Builder
BB.lazyByteString (ByteString -> Builder) -> μ ByteString -> μ Builder
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ ByteString
forall α (μ :: * -> *).
(RestDeserializable α, Deserializer μ) =>
μ α
getRest
{-# INLINE getRest #-}
instance (RestDeserializable α, RestDeserializable β)
⇒ RestDeserializable (Either α β) where
getRest :: μ (Either α β)
getRest = μ Word8
forall (μ :: * -> *). Deserializer μ => μ Word8
word8 μ Word8 -> (Word8 -> μ (Either α β)) -> μ (Either α β)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Word8
0 → α -> Either α β
forall a b. a -> Either a b
Left (α -> Either α β) -> μ α -> μ (Either α β)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ α
forall α (μ :: * -> *).
(RestDeserializable α, Deserializer μ) =>
μ α
getRest
Word8
1 → β -> Either α β
forall a b. b -> Either a b
Right (β -> Either α β) -> μ β -> μ (Either α β)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ β
forall α (μ :: * -> *).
(RestDeserializable α, Deserializer μ) =>
μ α
getRest
Word8
w → String -> μ (Either α β)
forall (m :: * -> *) a. Parsing m => String -> m a
unexpected (Word8 -> String
forall a. Show a => a -> String
show Word8
w)
{-# INLINABLE getRest #-}
instance (Deserializable α, RestDeserializable β)
⇒ RestDeserializable (α, β) where
getRest :: μ (α, β)
getRest = (,) (α -> β -> (α, β)) -> μ α -> μ (β -> (α, β))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ α
forall α (μ :: * -> *). (Deserializable α, Deserializer μ) => μ α
get μ (β -> (α, β)) -> μ β -> μ (α, β)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> μ β
forall α (μ :: * -> *).
(RestDeserializable α, Deserializer μ) =>
μ α
getRest
{-# INLINE getRest #-}
instance Deserializable α ⇒ RestDeserializable [α] where
getRest :: μ [α]
getRest = ([] [α] -> μ () -> μ [α]
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ μ ()
forall (m :: * -> *). Parsing m => m ()
eof) μ [α] -> μ [α] -> μ [α]
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ((:) (α -> [α] -> [α]) -> μ α -> μ ([α] -> [α])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> μ α
forall α (μ :: * -> *). (Deserializable α, Deserializer μ) => μ α
get μ ([α] -> [α]) -> μ [α] -> μ [α]
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> μ [α]
forall α (μ :: * -> *).
(RestDeserializable α, Deserializer μ) =>
μ α
getRest)