dynamic-state-0.3.2: Optionally serializable dynamic state keyed by type

License | GPL2
Maintainer | zcarterc@gmail.com
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

Extensions

- Cpp
- ScopedTypeVariables
- DeriveDataTypeable
- ExistentialQuantification
- TupleSections
- ExplicitForAll

Data.DynamicState.Serializable

Description

This module is HashMap ConcreteTypeRep Dynamic with a twist. The Dynamic used can also be ByteString, to make repeated reserialization cheap. A user-provided State-like is used to store this.

Synopsis

- newtype DynamicState = DynamicState {
  - unDynamicState :: HashMap ConcreteTypeRep Dynamic
  }
- getDyn :: forall m a. (Typeable a, Binary a, Monad m) => m DynamicState -> (DynamicState -> m ()) -> m (Maybe a)
- putDyn :: forall m a. (Typeable a, Binary a, Monad m) => m DynamicState -> (DynamicState -> m ()) -> a -> m ()

# Documentation

newtype DynamicState Source #

An extensible record, indexed by type, using state to cache deserializtion

Constructors

DynamicState |

Fields

- unDynamicState :: HashMap ConcreteTypeRep Dynamic

#### Instances

Instances details

Binary DynamicState Source # |
Instance details Defined in Data.DynamicState.Serializable Methods put :: DynamicState -> Put Source # get :: Get DynamicState Source # putList :: [DynamicState] -> Put Source #
Monoid DynamicState Source # |
Instance details Defined in Data.DynamicState.Serializable Methods mempty :: DynamicState Source # mappend :: DynamicState -> DynamicState -> DynamicState Source # mconcat :: [DynamicState] -> DynamicState Source #
Semigroup DynamicState Source # |
Instance details Defined in Data.DynamicState.Serializable Methods (<>) :: DynamicState -> DynamicState -> DynamicState Source # sconcat :: NonEmpty DynamicState -> DynamicState Source # stimes :: Integral b => b -> DynamicState -> DynamicState Source #

getDyn :: forall m a. (Typeable a, Binary a, Monad m) => m DynamicState -> (DynamicState -> m ()) -> m (Maybe a) Source #

Get a value, inside a State-like monad specified by the first two functions

putDyn :: forall m a. (Typeable a, Binary a, Monad m) => m DynamicState -> (DynamicState -> m ()) -> a -> m () Source #

Set a value, inside a State-like monad specified by the first two functions