ghc-7.10.3: The GHC API

Safe Haskell | None
Language | Haskell2010

Serialized

Contents

- Main Serialized data type
- Going into and out of `Serialized`
- Handy serialization functions

Synopsis

- data Serialized
- seqSerialized :: Serialized -> ()
- toSerialized :: Typeable a => (a -> [Word8]) -> a -> Serialized
- fromSerialized :: forall a. Typeable a => ([Word8] -> a) -> Serialized -> Maybe a
- serializeWithData :: Data a => a -> [Word8]
- deserializeWithData :: Data a => [Word8] -> a

# Main Serialized data type

data Serialized

Represents a serialized value of a particular type. Attempts can be made to deserialize it at certain types

Instances

Outputable Serialized |
Binary Serialized |

seqSerialized :: Serialized -> ()

Force the contents of the Serialized value so weknow it doesn't contain any bottoms

# Going into and out of `Serialized`

toSerialized :: Typeable a => (a -> [Word8]) -> a -> Serialized

Put a Typeable value that we are able to actually turn into bytes into a `Serialized` value ready for deserialization later

fromSerialized :: forall a. Typeable a => ([Word8] -> a) -> Serialized -> Maybe a

If the `Serialized` value contains something of the given type, then use the specified deserializer to return `Just` that. Otherwise return `Nothing`.

# Handy serialization functions

serializeWithData :: Data a => a -> [Word8]

Use a `Data` instance to implement a serialization scheme dual to that of `deserializeWithData`

deserializeWithData :: Data a => [Word8] -> a

Use a `Data` instance to implement a deserialization scheme dual to that of `serializeWithData`