haskus-binary-1.5: Haskus binary format manipulation

Safe HaskellNone
LanguageHaskell2010

Haskus.Binary.Serialize

Description

Binary serialization of Haskell values

Synopsis

Documentation

class Serializable a where Source #

Binary serializable data

Minimal complete definition

put, get

Associated Types

type SizeOf a :: Size Source #

Size of the data in bytes

type Endian a :: Bool Source #

Sensible to endianness

Methods

sizeOf :: a -> Word Source #

Dynamic size of the data in bytes

The default implementation execute the put method with a PutMonad that only stores the size in bytes. Overload this function if possible!

put :: PutMonad m => Endianness -> a -> m () Source #

Serialize a value

get :: GetMonad m => Endianness -> m a Source #

Deserialize a value

Instances
Serializable Int8 Source # 
Instance details

Defined in Haskus.Binary.Serialize

Associated Types

type SizeOf Int8 :: Size Source #

type Endian Int8 :: Bool Source #

Methods

sizeOf :: Int8 -> Word Source #

put :: PutMonad m => Endianness -> Int8 -> m () Source #

get :: GetMonad m => Endianness -> m Int8 Source #

Serializable Int16 Source # 
Instance details

Defined in Haskus.Binary.Serialize

Associated Types

type SizeOf Int16 :: Size Source #

type Endian Int16 :: Bool Source #

Methods

sizeOf :: Int16 -> Word Source #

put :: PutMonad m => Endianness -> Int16 -> m () Source #

get :: GetMonad m => Endianness -> m Int16 Source #

Serializable Int32 Source # 
Instance details

Defined in Haskus.Binary.Serialize

Associated Types

type SizeOf Int32 :: Size Source #

type Endian Int32 :: Bool Source #

Methods

sizeOf :: Int32 -> Word Source #

put :: PutMonad m => Endianness -> Int32 -> m () Source #

get :: GetMonad m => Endianness -> m Int32 Source #

Serializable Int64 Source # 
Instance details

Defined in Haskus.Binary.Serialize

Associated Types

type SizeOf Int64 :: Size Source #

type Endian Int64 :: Bool Source #

Methods

sizeOf :: Int64 -> Word Source #

put :: PutMonad m => Endianness -> Int64 -> m () Source #

get :: GetMonad m => Endianness -> m Int64 Source #

Serializable Word8 Source # 
Instance details

Defined in Haskus.Binary.Serialize

Associated Types

type SizeOf Word8 :: Size Source #

type Endian Word8 :: Bool Source #

Methods

sizeOf :: Word8 -> Word Source #

put :: PutMonad m => Endianness -> Word8 -> m () Source #

get :: GetMonad m => Endianness -> m Word8 Source #

Serializable Word16 Source # 
Instance details

Defined in Haskus.Binary.Serialize

Associated Types

type SizeOf Word16 :: Size Source #

type Endian Word16 :: Bool Source #

Serializable Word32 Source # 
Instance details

Defined in Haskus.Binary.Serialize

Associated Types

type SizeOf Word32 :: Size Source #

type Endian Word32 :: Bool Source #

Serializable Word64 Source # 
Instance details

Defined in Haskus.Binary.Serialize

Associated Types

type SizeOf Word64 :: Size Source #

type Endian Word64 :: Bool Source #

Serializable a => Serializable (AsLittleEndian a) Source # 
Instance details

Defined in Haskus.Binary.Serialize

Associated Types

type SizeOf (AsLittleEndian a) :: Size Source #

type Endian (AsLittleEndian a) :: Bool Source #

Serializable a => Serializable (AsBigEndian a) Source # 
Instance details

Defined in Haskus.Binary.Serialize

Associated Types

type SizeOf (AsBigEndian a) :: Size Source #

type Endian (AsBigEndian a) :: Bool Source #

data Size Source #

Size in bytes

Constructors

Exactly Nat

Exactly the given size

Dynamic

Dynamically known size (the size is stored with the object)