ghc-lib-parser-9.12.2.20250421: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Serialized

Contents

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

Synopsis

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

# Main Serialized data type

data Serialized Source #

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

Constructors

Serialized TypeRep [Word8] |

#### Instances

Instances details

Binary Serialized Source # |
Instance details Defined in GHCi.TH.Binary Methods put :: Serialized -> Put Source # get :: Get Serialized Source # putList :: [Serialized] -> Put Source #
Binary Serialized Source # |
Instance details Defined in GHC.Utils.Binary.Typeable Methods put_ :: WriteBinHandle -> Serialized -> IO () Source # put :: WriteBinHandle -> Serialized -> IO (Bin Serialized) Source # get :: ReadBinHandle -> IO Serialized Source #
Outputable Serialized Source # |
Instance details Defined in GHC.Utils.Outputable Methods ppr :: Serialized -> SDoc Source #

# Going into and out of `Serialized`

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

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

fromSerialized :: Typeable a => ([Word8] -> a) -> Serialized -> Maybe a Source #

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] Source #

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

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

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