packages feed

creatur 4.1.7 → 4.2.0

raw patch · 3 files changed

+12/−5 lines, 3 files

Files

creatur.cabal view
@@ -1,5 +1,5 @@ Name:              creatur-Version:           4.1.7+Version:           4.2.0 Stability:         experimental Synopsis:          Framework for artificial life experiments. Description:       A software framework for automating experiments
src/ALife/Creatur/Counter.hs view
@@ -20,7 +20,8 @@ import ALife.Creatur.Clock (Clock, currentTime, incTime) import ALife.Creatur.Util (modifyLift, getLift) import Control.Monad (unless)-import Control.Monad.State (StateT, gets, modify)+import Control.Monad.IO.Class (liftIO)+import Control.Monad.State (StateT, get, gets, modify) import System.Directory (doesFileExist) import System.IO (hGetContents, withFile, Handle, IOMode(ReadMode)) import Text.Read (readEither)@@ -43,7 +44,8 @@   current = initIfNeeded >> gets cValue   increment = do     modify (\c -> c { cValue=1 + cValue c })-    getLift store+    k <- get+    liftIO $ store k  store :: PersistentCounter -> IO () store counter = writeFile (cFilename counter) $ show (cValue counter)@@ -51,7 +53,7 @@ initIfNeeded :: StateT PersistentCounter IO () initIfNeeded = do   isInitialised <- gets cInitialised-  unless isInitialised $ modifyLift initialise+  unless isInitialised $ modifyLift initialise >> getLift store  initialise :: PersistentCounter -> IO PersistentCounter initialise counter = do@@ -63,7 +65,10 @@       case x of         Left msg -> error $ "Unable to read counter from " ++ f ++ ": " ++ msg         Right c  -> return $ counter { cInitialised=True, cValue=c }-    else return $ counter { cInitialised=True, cValue=0 }+    else do+      let k = counter { cInitialised=True, cValue=0 }+      store k+      return k  instance Clock PersistentCounter where   currentTime = current
test/Main.hs view
@@ -12,6 +12,7 @@ ------------------------------------------------------------------------ module Main where +import ALife.Creatur.CounterQC (test) import ALife.Creatur.Database.FileSystemQC (test) import ALife.Creatur.UtilQC (test) import ALife.Creatur.Genetics.CodeQC (test)@@ -25,6 +26,7 @@ tests :: [TF.Test] tests =    [ +    ALife.Creatur.CounterQC.test,     ALife.Creatur.Database.FileSystemQC.test,     ALife.Creatur.UtilQC.test,     ALife.Creatur.Genetics.CodeQC.test,