dynamic-state 0.1.0.1 → 0.1.0.2
raw patch · 2 files changed
+3/−3 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
dynamic-state.cabal view
@@ -1,5 +1,5 @@ name: dynamic-state-version: 0.1.0.1+version: 0.1.0.2 synopsis: Optionally serializable dynamic state keyed by type description: Optionally serializable dynamic state keyed by type license: BSD3
src/Data/DynamicState/Serializable.hs view
@@ -61,10 +61,10 @@ -- | Get a value, inside a State-like monad specified by the first two functions getDyn :: forall m a. (Typeable a, Binary a, Monad m) => m DynamicState -> (DynamicState -> m ()) -> m (Maybe a) getDyn get' put' = do- let ty = (cTypeOf (undefined::a))+ let ty = cTypeOf (undefined::a) dvs <- liftM unDynamicState get' case M.lookup ty dvs >>= fromDynamic of- Just (val,new) -> (when new $ put' $ DynamicState $ M.insert ty (Dynamic val) dvs) >> return val+ Just (val,new) -> (when new $ put' $ DynamicState $ M.insert ty (Dynamic val) dvs) >> return (Just val) Nothing -> return Nothing -- | Set 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 ()