packages feed

acid-state 0.4.1 → 0.4.2

raw patch · 4 files changed

+28/−18 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.Acid.Local: instance Applicative (Query st)
+ Data.Acid.Local: instance Applicative (Update st)
+ Data.Acid.Local: instance Functor (Query st)
+ Data.Acid.Local: instance Functor (Update st)

Files

acid-state.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version:             0.4.1+Version:             0.4.2  -- A short (one-line) description of the package. Synopsis:            Add ACID guarantees to any serializable Haskell data structure.
examples/StressTest.hs view
@@ -31,8 +31,11 @@ queryState = do StressState i <- ask                 return i -$(makeAcidic ''StressState ['pokeState, 'queryState])+clearState :: Update StressState ()+clearState = put $ StressState 0 +$(makeAcidic ''StressState ['pokeState, 'queryState, 'clearState])+ ------------------------------------------------------ -- This is how AcidState is used: @@ -53,6 +56,10 @@                     replicateM_ (100000-1) (scheduleUpdate acid PokeState)                     update acid PokeState                     putStrLn "Done"+            ["clear"]+              -> do acid <- openAcidState (StressState 0)+                    update acid ClearState+                    createCheckpoint acid             _ -> do putStrLn $ "Commands:"                     putStrLn $ "  query            Prints out the current state."                     putStrLn $ "  poke             Spawn 100k transactions."
src/Data/Acid/Local.hs view
@@ -55,6 +55,8 @@ import Data.Typeable                  ( Typeable, typeOf ) import System.FilePath                ( (</>) ) +import Control.Applicative            (Applicative(..))+ -- | Events return the same thing as Methods. The exact type of 'EventResult' --   depends on the event. type EventResult ev = MethodResult ev@@ -106,11 +108,11 @@  -- | Context monad for Update events. newtype Update st a = Update { unUpdate :: State st a }-    deriving (Monad, MonadState st)+    deriving (Monad, Functor, Applicative, MonadState st)  -- | Context monad for Query events. newtype Query st a  = Query { unQuery :: Reader st a }-    deriving (Monad, MonadReader st)+    deriving (Monad, Functor, Applicative, MonadReader st)  -- | Run a query in the Update Monad. runQuery :: Query st a -> Update st a@@ -121,7 +123,7 @@ -- | Issue an Update event and wait for its result. Once this call returns, you are --   guaranteed that the changes to the state are durable. Events may be issued in --   parallel.---   +-- --   It's a run-time error to issue events that aren't supported by the AcidState. update :: UpdateEvent event => AcidState (EventState event) -> event -> IO (EventResult event) update acidState event@@ -179,7 +181,7 @@ --   makes it faster to resume AcidStates and you're free to create them as --   often or seldom as fits your needs. Transactions can run concurrently --   with this call.---   +-- --   This call will not return until the operation has succeeded. createCheckpoint :: SafeCopy st => AcidState st -> IO () createCheckpoint acidState@@ -221,7 +223,7 @@       -- ^ List of events capable of updating or querying the state.  -- | Create an AcidState given an initial value.---   +-- --   This will create or resume a log found in the \"state\/[typeOf state]\/\" directory. openAcidState :: (Typeable st, IsAcidic st)               => st                          -- ^ Initial state value. This value is only used if no checkpoint is@@ -231,7 +233,7 @@     = openAcidStateFrom ("state" </> show (typeOf initialState)) initialState  -- | Create an AcidState given a log directory and an initial value.---   +-- --   This will create or resume a log found in @directory@. --   Running two AcidState's from the same directory is an error --   but will not result in dataloss.@@ -255,7 +257,7 @@                                                                Left msg  -> checkpointRestoreError msg                                                                Right val -> return val)                         return eventCutOff-         +          eventsLog <- openFileLog eventsLogKey          events <- readEntriesFrom eventsLog n          mapM_ (runColdMethod core) events
src/Data/Acid/TemplateHaskell.hs view
@@ -49,13 +49,20 @@                    -> makeAcidic' eventNames stateName tyvars constructors                  NewtypeD _cxt _name tyvars constructor _derivs                    -> makeAcidic' eventNames stateName tyvars [constructor]-                 _ -> error "Unsupported state type. Only 'data' and 'newtype' are supported."+                 TySynD _name tyvars _ty+                   -> makeAcidic' eventNames stateName tyvars []+                 _ -> error "Unsupported state type. Only 'data', 'newtype' and 'type' are supported."            _ -> error "Given state is not a type." +makeAcidic' :: [Name] -> Name -> [TyVarBndr] -> [Con] -> Q [Dec]+makeAcidic' eventNames stateName tyvars constructors+    = do events <- sequence [ makeEvent eventName | eventName <- eventNames ]+         acidic <- makeIsAcidic eventNames stateName tyvars constructors+         return $ acidic : concat events+ makeEvent :: Name -> Q [Dec] makeEvent eventName-    = do eventInfo <- reify eventName-         eventType <- getEventType eventName+    = do eventType <- getEventType eventName          d <- makeEventDataType eventName eventType          b <- makeSafeCopyInstance eventName eventType          i <- makeMethodInstance eventName eventType@@ -190,9 +197,3 @@               | con == ''Update = (state, result, True)               | con == ''Query  = (state, result, False)           findMonad _ = error $ "Event has an invalid type signature: Not an Update or a Query: " ++ show eventName--makeAcidic' :: [Name] -> Name -> [TyVarBndr] -> [Con] -> Q [Dec]-makeAcidic' eventNames stateName tyvars constructors-    = do events <- sequence [ makeEvent eventName | eventName <- eventNames ]-         acidic <- makeIsAcidic eventNames stateName tyvars constructors-         return $ acidic : concat events