packages feed

acid-state 0.14.1 → 0.14.2

raw patch · 4 files changed

+65/−2 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+0.14.2+======++ - createCheckpoint now cuts a new events file (bug #74)+ 0.14.1 ====== 
acid-state.cabal view
@@ -1,5 +1,5 @@ Name:                acid-state-Version:             0.14.1+Version:             0.14.2 Synopsis:            Add ACID guarantees to any serializable Haskell data structure. Description:         Use regular Haskell data structures as your database and get stronger ACID guarantees than most RDBMS offer. Homepage:            http://acid-state.seize.it/@@ -10,6 +10,7 @@ Category:            Database Build-type:          Simple Cabal-version:       >=1.10+tested-with:         GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.1 Extra-source-files:         CHANGELOG.md         examples/*.hs
+ examples/CheckpointCutsEvent.hs view
@@ -0,0 +1,56 @@+{-+This example is mostly just to test that this bug is fixed:++https://github.com/acid-state/acid-state/issues/73++At the end of a run, the checkpoint file should contain a single+checkpoint and the event file should be empty. The old checkpoints and+events should be in the Archive directory.++In the Acrhive directory, each checkpoint file should contain one+checkpoint, and each event file should contain 10 events.++If you comment out the 'createArchive' line below, then the checkpoint+files should contain 10 checkpoints each.++-}+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE TemplateHaskell    #-}+{-# LANGUAGE TypeFamilies       #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+module Main (main) where++-- import           Control.Concurrent+import           Control.Monad.Reader+import           Control.Monad.State+import           Data.Acid+import           Data.SafeCopy+import           Data.Typeable+import           System.Environment++------------------------------------------------------+-- The Haskell structure that we want to encapsulate++newtype Counter = Counter { unCounter :: Integer }+    deriving (Show, Typeable)++$(deriveSafeCopy 0 'base ''Counter)++incCounter :: Update Counter Integer+incCounter =+  do (Counter c) <- get+     let c' = succ c+     put (Counter c')+     return c'++$(makeAcidic ''Counter ['incCounter])+++main :: IO ()+main =+  do acid <- openLocalState (Counter 0)+     replicateM_ 10 $ do is <- replicateM 10 (update acid IncCounter)+                         print is+                         createCheckpoint acid+                         createArchive acid+     closeAcidState acid
src/Data/Acid/Local.hs view
@@ -179,7 +179,8 @@ --   This call will not return until the operation has succeeded. createLocalCheckpoint :: SafeCopy st => LocalState st -> IO () createLocalCheckpoint acidState-    = do mvar <- newEmptyMVar+    = do cutFileLog (localEvents acidState)+         mvar <- newEmptyMVar          withCoreState (localCore acidState) $ \st ->            do eventId <- askCurrentEntryId (localEvents acidState)               pushAction (localEvents acidState) $