-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Sharing code for serialization between binary and cereal
--
-- Sharing code for serialization between binary and cereal
@package bytes
@version 0.10
-- | This module generalizes the binary PutM and
-- cereal PutM monads in an ad hoc fashion to permit code
-- to be written that is compatible across them.
--
-- Moreover, this class permits code to be written to be portable over
-- various monad transformers applied to these as base monads.
module Data.Bytes.Put
class (Applicative m, Monad m) => MonadPut m where putWord8 = lift . putWord8 putByteString = lift . putByteString putLazyByteString = lift . putLazyByteString flush = lift flush putWord16le = lift . putWord16le putWord16be = lift . putWord16be putWord16host = lift . putWord16host putWord32le = lift . putWord32le putWord32be = lift . putWord32be putWord32host = lift . putWord32host putWord64le = lift . putWord64le putWord64be = lift . putWord64be putWord64host = lift . putWord64host putWordhost = lift . putWordhost
putWord8 :: MonadPut m => Word8 -> m ()
putByteString :: MonadPut m => ByteString -> m ()
putLazyByteString :: MonadPut m => ByteString -> m ()
flush :: MonadPut m => m ()
putWord16le :: MonadPut m => Word16 -> m ()
putWord16be :: MonadPut m => Word16 -> m ()
putWord16host :: MonadPut m => Word16 -> m ()
putWord32le :: MonadPut m => Word32 -> m ()
putWord32be :: MonadPut m => Word32 -> m ()
putWord32host :: MonadPut m => Word32 -> m ()
putWord64le :: MonadPut m => Word64 -> m ()
putWord64be :: MonadPut m => Word64 -> m ()
putWord64host :: MonadPut m => Word64 -> m ()
putWordhost :: MonadPut m => Word -> m ()
instance (MonadPut m, Monoid w) => MonadPut (RWST r w s m)
instance (MonadPut m, Monoid w) => MonadPut (RWST r w s m)
instance (MonadPut m, Monoid w) => MonadPut (WriterT w m)
instance (MonadPut m, Monoid w) => MonadPut (WriterT w m)
instance MonadPut m => MonadPut (ReaderT e m)
instance MonadPut m => MonadPut (StateT s m)
instance MonadPut m => MonadPut (StateT s m)
instance MonadPut PutM
instance MonadPut PutM
-- | This module generalizes the binary Get and
-- cereal Get monads in an ad hoc fashion to permit code
-- to be written that is compatible across them.
--
-- Moreover, this class permits code to be written to be portable over
-- various monad transformers applied to these as base monads.
module Data.Bytes.Get
class (Integral (Remaining m), Monad m, Applicative m) => MonadGet m where type family Remaining m :: * type family Bytes m :: * skip = lift . skip ensure = lift . ensure getBytes = lift . getBytes remaining = lift remaining isEmpty = lift isEmpty getWord8 = lift getWord8 getByteString = lift . getByteString getLazyByteString = lift . getLazyByteString getWord16be = lift getWord16be getWord16le = lift getWord16le getWord16host = lift getWord16host getWord32be = lift getWord32be getWord32le = lift getWord32le getWord32host = lift getWord32host getWord64be = lift getWord64be getWord64le = lift getWord64le getWord64host = lift getWord64host getWordhost = lift getWordhost
skip :: MonadGet m => Int -> m ()
ensure :: MonadGet m => Int -> m ByteString
lookAhead :: MonadGet m => m a -> m a
lookAheadM :: MonadGet m => m (Maybe a) -> m (Maybe a)
lookAheadE :: MonadGet m => m (Either a b) -> m (Either a b)
getBytes :: MonadGet m => Int -> m ByteString
remaining :: MonadGet m => m (Remaining m)
isEmpty :: MonadGet m => m Bool
getWord8 :: MonadGet m => m Word8
getByteString :: MonadGet m => Int -> m ByteString
getLazyByteString :: MonadGet m => Int64 -> m ByteString
getWord16be :: MonadGet m => m Word16
getWord16le :: MonadGet m => m Word16
getWord16host :: MonadGet m => m Word16
getWord32be :: MonadGet m => m Word32
getWord32le :: MonadGet m => m Word32
getWord32host :: MonadGet m => m Word32
getWord64be :: MonadGet m => m Word64
getWord64le :: MonadGet m => m Word64
getWord64host :: MonadGet m => m Word64
getWordhost :: MonadGet m => m Word
instance (MonadGet m, Monoid w) => MonadGet (RWST r w s m)
instance (MonadGet m, Monoid w) => MonadGet (RWST r w s m)
instance (MonadGet m, Monoid w) => MonadGet (WriterT w m)
instance (MonadGet m, Monoid w) => MonadGet (WriterT w m)
instance MonadGet m => MonadGet (ReaderT e m)
instance MonadGet m => MonadGet (StateT s m)
instance MonadGet m => MonadGet (StateT s m)
instance MonadGet Get
instance MonadGet Get
-- | This module generalizes the binary PutM and
-- cereal PutM monads in an ad hoc fashion to permit code
-- to be written that is compatible across them.
--
-- Moreover, this class permits code to be written to be portable over
-- various monad transformers applied to these as base monads.
module Data.Bytes.Serial
class Serial a where serialize = gserialize . from deserialize = liftM to gdeserialize
serialize :: (Serial a, MonadPut m) => a -> m ()
deserialize :: (Serial a, MonadGet m) => m a
-- | Used internally to provide generic serialization
class GSerial f
gserialize :: (GSerial f, MonadPut m) => f a -> m ()
gdeserialize :: (GSerial f, MonadGet m) => m (f a)
class Serial1 f where serializeWith f = gserializeWith f . from1 deserializeWith f = liftM to1 (gdeserializeWith f)
serializeWith :: (Serial1 f, MonadPut m) => (a -> m ()) -> f a -> m ()
deserializeWith :: (Serial1 f, MonadGet m) => m a -> m (f a)
serialize1 :: (MonadPut m, Serial1 f, Serial a) => f a -> m ()
deserialize1 :: (MonadGet m, Serial1 f, Serial a) => m (f a)
-- | Used internally to provide generic serialization
class GSerial1 f
gserializeWith :: (GSerial1 f, MonadPut m) => (a -> m ()) -> f a -> m ()
gdeserializeWith :: (GSerial1 f, MonadGet m) => m a -> m (f a)
class Serial2 f
serializeWith2 :: (Serial2 f, MonadPut m) => (a -> m ()) -> (b -> m ()) -> f a b -> m ()
deserializeWith2 :: (Serial2 f, MonadGet m) => m a -> m b -> m (f a b)
serialize2 :: (MonadPut m, Serial2 f, Serial a, Serial b) => f a b -> m ()
deserialize2 :: (MonadGet m, Serial2 f, Serial a, Serial b) => m (f a b)
store :: (MonadPut m, Storable a) => a -> m ()
restore :: (MonadGet m, Storable a) => m a
instance Serial2 Map
instance (Serial a, Serial b, Serial c) => Serial2 ((,,,,) a b c)
instance (Serial a, Serial b) => Serial2 ((,,,) a b)
instance Serial a => Serial2 ((,,) a)
instance Serial2 (,)
instance Serial2 Either
instance Serial a => GSerial1 (K1 i a)
instance GSerial1 f => GSerial1 (M1 i c f)
instance (GSerial1 f, GSerial1 g) => GSerial1 (f :+: g)
instance (GSerial1 f, GSerial1 g) => GSerial1 (f :*: g)
instance GSerial1 V1
instance GSerial1 U1
instance GSerial1 f => GSerial1 (Rec1 f)
instance GSerial1 Par1
instance Serial k => Serial1 (Map k)
instance Serial1 IntMap
instance Serial1 Set
instance Serial1 Seq
instance (Serial a, Serial b, Serial c, Serial d) => Serial1 ((,,,,) a b c d)
instance (Serial a, Serial b, Serial c) => Serial1 ((,,,) a b c)
instance (Serial a, Serial b) => Serial1 ((,,) a b)
instance Serial a => Serial1 ((,) a)
instance Serial a => Serial1 (Either a)
instance Serial1 Maybe
instance Serial1 []
instance Serial a => GSerial (K1 i a)
instance GSerial f => GSerial (M1 i c f)
instance (GSerial f, GSerial g) => GSerial (f :+: g)
instance (GSerial f, GSerial g) => GSerial (f :*: g)
instance GSerial V1
instance GSerial U1
instance (Serial k, Serial v) => Serial (Map k v)
instance Serial v => Serial (IntMap v)
instance Serial a => Serial (Set a)
instance Serial a => Serial (Seq a)
instance Serial IntSet
instance Serial Void
instance Serial Int8
instance Serial Int16
instance Serial Int32
instance Serial Int64
instance Serial Int
instance Serial Word8
instance Serial Word16
instance Serial Word32
instance Serial Word64
instance Serial Word
instance Serial Char
instance Serial Float
instance Serial Double
instance Serial Bool
instance (Serial a, Serial b, Serial c, Serial d, Serial e) => Serial (a, b, c, d, e)
instance (Serial a, Serial b, Serial c, Serial d) => Serial (a, b, c, d)
instance (Serial a, Serial b, Serial c) => Serial (a, b, c)
instance (Serial a, Serial b) => Serial (a, b)
instance (Serial a, Serial b) => Serial (Either a b)
instance Serial a => Serial (Maybe a)
instance Serial a => Serial [a]
instance Serial ()
instance Serial Text
instance Serial Text
instance Serial ByteString
instance Serial ByteString