| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Dynamic.Binary
Description
The Dynamic type
This Dynamic is a variant of the Dynamic
from base:Data.Dynamic with a Binary instance.
It encapsulates a value of an arbitrary
type, provided that the type is instance of both
Typeable and Binary.
The advantage over just using a ByteString is the type safety:
Raw ByteStrings have no associated type, and the Binary
interface makes no guarantee that the representations for
values of different types are different.
The advantage over using a type-tagged ByteString is that
Dynamic avoids unnecessary encoding/decoding by internally
containing either a ByteString or a decoded value.
Converting to and from Dynamic
toDyn :: (Typeable a, Binary a) => a -> Dynamic Source #
Converts an arbitrary value into an object of type Dynamic.
Arguments
| :: (Typeable a, Binary a) | |
| => Dynamic | |
| -> a | default value |
| -> a | if types match, the value contained in the |
Converts a Dynamic object back into an ordinary Haskell value of
the correct type.
Arguments
| :: (Typeable a, Binary a) | |
| => Dynamic | |
| -> Maybe a | if types match, |
Converts a Dynamic object back into an ordinary Haskell value of
the correct type.
Accessor for the contained TypeRep
dynTypeRep :: Dynamic -> TypeRep Source #
Getter for the TypeRep of this Dynamic.