packages feed

acid-state 0.13.0 → 0.13.1

raw patch · 4 files changed

+32/−18 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Data.Acid.Abstract: _query :: AcidState st -> forall event. (QueryEvent event, EventState event ~ st) => event -> IO (EventResult event)
- Data.Acid.Abstract: _scheduleUpdate :: AcidState st -> forall event. (UpdateEvent event, EventState event ~ st) => event -> IO (MVar (EventResult event))
- Data.Acid.Abstract: acidSubState :: AcidState st -> AnyState st
- Data.Acid.Abstract: closeAcidState :: AcidState st -> IO ()
- Data.Acid.Abstract: createArchive :: AcidState st -> IO ()
- Data.Acid.Abstract: createCheckpoint :: AcidState st -> IO ()
- Data.Acid.Abstract: queryCold :: AcidState st -> Tagged ByteString -> IO ByteString
- Data.Acid.Abstract: scheduleColdUpdate :: AcidState st -> Tagged ByteString -> IO (MVar ByteString)
- Data.Acid.Local: instance SafeCopy Checkpoint
- Data.Acid.Local: instance Typeable LocalState
- Data.Acid.Local: localCheckpoints :: LocalState st -> FileLog Checkpoint
- Data.Acid.Local: localCopy :: LocalState st -> IORef st
- Data.Acid.Local: localCore :: LocalState st -> Core st
- Data.Acid.Local: localEvents :: LocalState st -> FileLog (Tagged ByteString)
- Data.Acid.Local: localLock :: LocalState st -> PrefixLock
- Data.Acid.Log: logCurrent :: FileLog object -> MVar FHandle
- Data.Acid.Log: logDirectory :: LogKey object -> FilePath
- Data.Acid.Log: logIdentifier :: FileLog object -> LogKey object
- Data.Acid.Log: logNextEntryId :: FileLog object -> TVar EntryId
- Data.Acid.Log: logPrefix :: LogKey object -> String
- Data.Acid.Log: logQueue :: FileLog object -> TVar ([ByteString], [IO ()])
- Data.Acid.Log: logThreads :: FileLog object -> [ThreadId]
- Data.Acid.Memory: instance Typeable MemoryState
- Data.Acid.Remote: ccClose :: CommChannel -> IO ()
- Data.Acid.Remote: ccGetSome :: CommChannel -> Int -> IO (ByteString)
- Data.Acid.Remote: ccPut :: CommChannel -> ByteString -> IO ()
- Data.Acid.Remote: instance Eq AcidRemoteException
- Data.Acid.Remote: instance Exception AcidRemoteException
- Data.Acid.Remote: instance Serialize Command
- Data.Acid.Remote: instance Serialize Response
- Data.Acid.Remote: instance Show AcidRemoteException
- Data.Acid.Remote: instance Typeable AcidRemoteException
- Data.Acid.Remote: instance Typeable RemoteState
+ Data.Acid.Abstract: [_query] :: AcidState st -> forall event. (QueryEvent event, EventState event ~ st) => event -> IO (EventResult event)
+ Data.Acid.Abstract: [_scheduleUpdate] :: AcidState st -> forall event. (UpdateEvent event, EventState event ~ st) => event -> IO (MVar (EventResult event))
+ Data.Acid.Abstract: [acidSubState] :: AcidState st -> AnyState st
+ Data.Acid.Abstract: [closeAcidState] :: AcidState st -> IO ()
+ Data.Acid.Abstract: [createArchive] :: AcidState st -> IO ()
+ Data.Acid.Abstract: [createCheckpoint] :: AcidState st -> IO ()
+ Data.Acid.Abstract: [queryCold] :: AcidState st -> Tagged ByteString -> IO ByteString
+ Data.Acid.Abstract: [scheduleColdUpdate] :: AcidState st -> Tagged ByteString -> IO (MVar ByteString)
+ Data.Acid.Local: [localCheckpoints] :: LocalState st -> FileLog Checkpoint
+ Data.Acid.Local: [localCopy] :: LocalState st -> IORef st
+ Data.Acid.Local: [localCore] :: LocalState st -> Core st
+ Data.Acid.Local: [localEvents] :: LocalState st -> FileLog (Tagged ByteString)
+ Data.Acid.Local: [localLock] :: LocalState st -> PrefixLock
+ Data.Acid.Local: instance Data.SafeCopy.SafeCopy.SafeCopy Data.Acid.Local.Checkpoint
+ Data.Acid.Log: [logCurrent] :: FileLog object -> MVar FHandle
+ Data.Acid.Log: [logDirectory] :: LogKey object -> FilePath
+ Data.Acid.Log: [logIdentifier] :: FileLog object -> LogKey object
+ Data.Acid.Log: [logNextEntryId] :: FileLog object -> TVar EntryId
+ Data.Acid.Log: [logPrefix] :: LogKey object -> String
+ Data.Acid.Log: [logQueue] :: FileLog object -> TVar ([ByteString], [IO ()])
+ Data.Acid.Log: [logThreads] :: FileLog object -> [ThreadId]
+ Data.Acid.Remote: [ccClose] :: CommChannel -> IO ()
+ Data.Acid.Remote: [ccGetSome] :: CommChannel -> Int -> IO (ByteString)
+ Data.Acid.Remote: [ccPut] :: CommChannel -> ByteString -> IO ()
+ Data.Acid.Remote: instance Data.Serialize.Serialize Data.Acid.Remote.Command
+ Data.Acid.Remote: instance Data.Serialize.Serialize Data.Acid.Remote.Response
+ Data.Acid.Remote: instance GHC.Classes.Eq Data.Acid.Remote.AcidRemoteException
+ Data.Acid.Remote: instance GHC.Exception.Exception Data.Acid.Remote.AcidRemoteException
+ Data.Acid.Remote: instance GHC.Show.Show Data.Acid.Remote.AcidRemoteException
- Data.Acid: class SafeCopy st => IsAcidic st
+ Data.Acid: class (SafeCopy st) => IsAcidic st
- Data.Acid: openLocalStateFrom :: IsAcidic st => FilePath -> st -> IO (AcidState st)
+ Data.Acid: openLocalStateFrom :: (IsAcidic st) => FilePath -> st -> IO (AcidState st)
- Data.Acid.Advanced: class SafeCopy st => IsAcidic st
+ Data.Acid.Advanced: class (SafeCopy st) => IsAcidic st
- Data.Acid.Local: openLocalStateFrom :: IsAcidic st => FilePath -> st -> IO (AcidState st)
+ Data.Acid.Local: openLocalStateFrom :: (IsAcidic st) => FilePath -> st -> IO (AcidState st)
- Data.Acid.Local: prepareLocalStateFrom :: IsAcidic st => FilePath -> st -> IO (IO (AcidState st))
+ Data.Acid.Local: prepareLocalStateFrom :: (IsAcidic st) => FilePath -> st -> IO (IO (AcidState st))
- Data.Acid.Memory: openMemoryState :: IsAcidic st => st -> IO (AcidState st)
+ Data.Acid.Memory: openMemoryState :: (IsAcidic st) => st -> IO (AcidState st)
- Data.Acid.Memory.Pure: class SafeCopy st => IsAcidic st
+ Data.Acid.Memory.Pure: class (SafeCopy st) => IsAcidic st

Files

acid-state.cabal view
@@ -1,5 +1,5 @@ Name:                acid-state-Version:             0.13.0+Version:             0.13.1 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/
src/Data/Acid/Log.hs view
@@ -43,6 +43,7 @@  import Paths_acid_state                          ( version ) import Data.Version                              ( showVersion )+import Control.Exception                         ( handle, IOException )  type EntryId = Int @@ -87,7 +88,8 @@   currentState <- newEmptyMVar   queue <- newTVarIO ([], [])   nextEntryRef <- newTVarIO 0-  tid2 <- forkIO $ fileWriter currentState queue+  tid1 <- myThreadId+  tid2 <- forkIO $ fileWriter currentState queue tid1   let fLog = FileLog { logIdentifier  = identifier                      , logCurrent     = currentState                      , logNextEntryId = nextEntryRef@@ -105,16 +107,17 @@              putMVar currentState handle   return fLog -fileWriter :: MVar FHandle -> TVar ([Lazy.ByteString], [IO ()]) -> IO ()-fileWriter currentState queue = forever $ do+fileWriter :: MVar FHandle -> TVar ([Lazy.ByteString], [IO ()]) -> ThreadId -> IO ()+fileWriter currentState queue parentTid = forever $ do   (entries, actions) <- atomically $ do     (entries, actions) <- readTVar queue     when (null entries && null actions) retry     writeTVar queue ([], [])     return (reverse entries, reverse actions)-  withMVar currentState $ \fd -> do-    let arch = Archive.packEntries entries-    writeToDisk fd (repack arch)+  handle (\e -> throwTo parentTid (e :: IOException)) $+    withMVar currentState $ \fd -> do+      let arch = Archive.packEntries entries+      writeToDisk fd (repack arch)   sequence_ actions   yield 
src/Data/Acid/Memory/Pure.hs view
@@ -7,7 +7,7 @@ -- Maintainer  :  lemmih@gmail.com -- Portability :  non-portable (uses GHC extensions) ----- AcidState container without a transaction log. Mostly used for testing. +-- AcidState container without a transaction log. Mostly used for testing. --  module Data.Acid.Memory.Pure@@ -80,10 +80,10 @@  -- | Create an AcidState given an initial value. openAcidState :: IsAcidic st-              => st                          -- ^ Initial state value. +              => st                          -- ^ Initial state value.               -> AcidState st openAcidState initialState-    = AcidState { localMethods = mkMethodMap (eventsToMethods acidEvents) +    = AcidState { localMethods = mkMethodMap (eventsToMethods acidEvents)                 , localState   = initialState }  -- | Execute the 'Update' monad in a pure environment.
src/Data/Acid/TemplateHaskell.hs view
@@ -11,6 +11,7 @@ import Data.Acid.Common  import Data.List ((\\), nub)+import Data.Maybe (mapMaybe) import Data.SafeCopy import Data.Typeable import Data.Char@@ -91,7 +92,7 @@          cxts' <- mkCxtFromTyVars preds tyvars cxtFromEvents          instanceD (return cxts') ty                    [ valD (varP 'acidEvents) (normalB (listE handlers)) [] ]-    where stateType = foldl appT (conT stateName) [ varT var | PlainTV var <- tyvars ]+    where stateType = foldl appT (conT stateName) (map varT (allTyVarBndrNames tyvars))  -- | This function analyses an event function and extracts any -- additional class contexts which need to be added to the IsAcidic@@ -226,7 +227,7 @@ --    get = MyUpdateEvent <$> get <*> get makeSafeCopyInstance eventName eventType     = do let preds = [ ''SafeCopy ]-             ty = AppT (ConT ''SafeCopy) (foldl AppT (ConT eventStructName) [ VarT tyvar | PlainTV tyvar <- tyvars ])+             ty = AppT (ConT ''SafeCopy) (foldl AppT (ConT eventStructName) (map VarT (allTyVarBndrNames tyvars)))               getBase = appE (varE 'return) (conE eventStructName)              getArgs = foldl (\a b -> infixE (Just a) (varE '(<*>)) (Just (varE 'safeGet))) getBase args@@ -248,7 +249,7 @@           structName (x:xs) = toUpper x : xs  mkCxtFromTyVars preds tyvars extraContext-    = cxt $ [ classP classPred [varT tyvar] | PlainTV tyvar <- tyvars, classPred <- preds ] +++    = cxt $ [ classP classPred [varT tyvar] | tyvar <- plainTyVarBndrNames tyvars, classPred <- preds ] ++             map return extraContext  {-@@ -259,9 +260,9 @@ -} makeMethodInstance eventName eventType     = do let preds = [ ''SafeCopy, ''Typeable ]-             ty = AppT (ConT ''Method) (foldl AppT (ConT eventStructName) [ VarT tyvar | PlainTV tyvar <- tyvars ])-             structType = foldl appT (conT eventStructName) [ varT tyvar | PlainTV tyvar <- tyvars ]-         instanceD (cxt $ [ classP classPred [varT tyvar] | PlainTV tyvar <- tyvars, classPred <- preds ] ++ map return context)+             ty = AppT (ConT ''Method) (foldl AppT (ConT eventStructName) (map VarT (allTyVarBndrNames tyvars)))+             structType = foldl appT (conT eventStructName) (map varT (allTyVarBndrNames tyvars))+         instanceD (cxt $ [ classP classPred [varT tyvar] | tyvar <- plainTyVarBndrNames tyvars, classPred <- preds ] ++ map return context)                    (return ty) #if __GLASGOW_HASKELL__ >= 707                    [ tySynInstD ''MethodResult (tySynEqn [structType] (return resultType))@@ -281,8 +282,8 @@ makeEventInstance eventName eventType     = do let preds = [ ''SafeCopy, ''Typeable ]              eventClass = if isUpdate then ''UpdateEvent else ''QueryEvent-             ty = AppT (ConT eventClass) (foldl AppT (ConT eventStructName) [ VarT tyvar | PlainTV tyvar <- tyvars ])-         instanceD (cxt $ [ classP classPred [varT tyvar] | PlainTV tyvar <- tyvars, classPred <- preds ] ++ map return context)+             ty = AppT (ConT eventClass) (foldl AppT (ConT eventStructName) (map VarT (allTyVarBndrNames tyvars)))+         instanceD (cxt $ [ classP classPred [varT tyvar] | tyvar <- plainTyVarBndrNames tyvars, classPred <- preds ] ++ map return context)                    (return ty)                    []     where (tyvars, context, _args, _stateType, _resultType, isUpdate) = analyseType eventName eventType@@ -327,3 +328,13 @@ tyVarBndrName :: TyVarBndr -> Name tyVarBndrName (PlainTV n)    = n tyVarBndrName (KindedTV n _) = n++plainTyVarBndrName :: TyVarBndr -> Maybe Name+plainTyVarBndrName (PlainTV name) = Just name+plainTyVarBndrName _ = Nothing++plainTyVarBndrNames :: [TyVarBndr] -> [Name]+plainTyVarBndrNames tyvars = mapMaybe plainTyVarBndrName tyvars++allTyVarBndrNames :: [TyVarBndr] -> [Name]+allTyVarBndrNames tyvars = map tyVarBndrName tyvars