creatur 5.9.23 → 5.9.25
raw patch · 44 files changed
+263/−246 lines, 44 filesdep −old-localedep −processdep −zlibdep ~HUnitdep ~MonadRandomdep ~QuickChecksetup-changed
Dependencies removed: old-locale, process, zlib
Dependency ranges changed: HUnit, MonadRandom, QuickCheck, array, base, binary, bytestring, cereal, cond, directory, exceptions, filepath, gray-extended, hdaemonize, hsyslog, mtl, random, split, temporary, test-framework, test-framework-hunit, test-framework-quickcheck2, time, transformers, unix
Files
- ChangeLog.md +7/−0
- LICENSE +4/−4
- README.md +20/−0
- Setup.hs +0/−0
- creatur.cabal +112/−131
- src/ALife/Creatur.hs +1/−1
- src/ALife/Creatur/Checklist.hs +1/−1
- src/ALife/Creatur/Clock.hs +1/−1
- src/ALife/Creatur/Counter.hs +1/−1
- src/ALife/Creatur/Daemon.hs +17/−8
- src/ALife/Creatur/Database.hs +1/−1
- src/ALife/Creatur/Database/CachedFileSystem.hs +1/−1
- src/ALife/Creatur/Database/CachedFileSystemInternal.hs +1/−1
- src/ALife/Creatur/Database/FileSystem.hs +1/−1
- src/ALife/Creatur/Genetics/Analysis.hs +1/−1
- src/ALife/Creatur/Genetics/BRGCBool.hs +1/−1
- src/ALife/Creatur/Genetics/BRGCWord16.hs +1/−1
- src/ALife/Creatur/Genetics/BRGCWord8.hs +1/−1
- src/ALife/Creatur/Genetics/Diploid.hs +1/−1
- src/ALife/Creatur/Genetics/Recombination.hs +1/−1
- src/ALife/Creatur/Genetics/Reproduction/Sexual.hs +1/−1
- src/ALife/Creatur/Genetics/Reproduction/SimplifiedSexual.hs +1/−1
- src/ALife/Creatur/Logger.hs +1/−1
- src/ALife/Creatur/Logger/SimpleLogger.hs +1/−1
- src/ALife/Creatur/Logger/SimpleRotatingLogger.hs +1/−1
- src/ALife/Creatur/Namer.hs +1/−1
- src/ALife/Creatur/Persistent.hs +1/−1
- src/ALife/Creatur/Task.hs +1/−1
- src/ALife/Creatur/Universe.hs +1/−1
- src/ALife/Creatur/Util.hs +19/−19
- test/ALife/Creatur/ChecklistQC.hs +1/−1
- test/ALife/Creatur/CounterQC.hs +1/−1
- test/ALife/Creatur/Database/CachedFileSystemQC.hs +1/−1
- test/ALife/Creatur/Database/FileSystemQC.hs +1/−1
- test/ALife/Creatur/Genetics/BRGCBoolQC.hs +1/−1
- test/ALife/Creatur/Genetics/BRGCWord16QC.hs +1/−1
- test/ALife/Creatur/Genetics/BRGCWord8QC.hs +1/−1
- test/ALife/Creatur/Genetics/DiploidQC.hs +1/−1
- test/ALife/Creatur/Genetics/RecombinationQC.hs +1/−1
- test/ALife/Creatur/PersistentQC.hs +1/−1
- test/ALife/Creatur/UniverseQC.hs +1/−1
- test/ALife/Creatur/UtilQC.hs +1/−1
- test/Spec.hs +49/−0
- test/TestAll.hs +0/−49
+ ChangeLog.md view
@@ -0,0 +1,7 @@+# Changelog for creatur++5.9.25 Fixed copyright year.+5.9.24 Revamped to work with Stack v1.7.1.+ Added exception handling.++## Unreleased changes
LICENSE view
@@ -1,9 +1,9 @@-Copyright (c) Amy de Buitléir 2010-2015+Copyright Amy de Buitléir (c) 2010-2018+ All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met:+Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ README.md view
@@ -0,0 +1,20 @@+Créatúr+=======++Créatúr is a software framework for automating experiments+with artificial life (ALife) or other evolutionary algorithms (EA). +It provides a daemon which ensures that each agent gets its turn +to use the CPU. +You can use other applications on the computer at the same time+without fear of interfering with experiments; they+will run normally (although perhaps more slowly).+Créatúr also provides a library of modules to help you implement your own +ALife species.+Even if you aren't using the Créatúr framework, you may find some of these+modules useful.++A tutorial on how to use Créatúr, including lots of examples,+is available at https://github.com/mhwombat/creatur-examples/raw/master/Tutorial.pdf.++Créatúr (pronounced kray-toor) is an irish word +meaning animal, creature, or unfortunate person.
Setup.hs view
creatur.cabal view
@@ -1,135 +1,116 @@-name: creatur-version: 5.9.23-cabal-version: >=1.8-build-type: Simple-license: BSD3-license-file: LICENSE-copyright: (c) Amy de Buitléir 2010-2017-maintainer: amy@nualeargais.ie-stability: experimental-homepage: https://github.com/mhwombat/creatur-bug-reports: https://github.com/mhwombat/creatur/issues-synopsis: Framework for artificial life experiments.-description:- A software framework for automating experiments- with artificial life. It provides a daemon which- maintains its own "clock", schedules events,- provides logging, and ensures that each agent gets- its turn to use the CPU. You can use other- applications on the computer at the same time- without fear of interfering with experiments; they- will run normally, just more slowly. See the- tutorial at- <https://github.com/mhwombat/creatur-examples/raw/master/Tutorial.pdf>- for examples on how to use the- Créatúr framework.- .- About the name: \"Créatúr\" (pronounced kray-toor)- is an Irish word meaning animal, creature, or an- unfortunate person.-category: AI-author: Amy de Buitléir+-- This file has been generated from package.yaml by hpack version 0.28.2.+--+-- see: https://github.com/sol/hpack+--+-- hash: 048046df2d9a1e1637467cdb014536ba03c606ad0122b3f586667501ef879d37 -library- exposed-modules:- ALife.Creatur- ALife.Creatur.Checklist- ALife.Creatur.Clock- ALife.Creatur.Counter- ALife.Creatur.Daemon- ALife.Creatur.Database- ALife.Creatur.Database.CachedFileSystem- ALife.Creatur.Database.CachedFileSystemInternal- ALife.Creatur.Database.FileSystem- ALife.Creatur.Genetics.Analysis- ALife.Creatur.Genetics.BRGCBool- ALife.Creatur.Genetics.BRGCWord8- ALife.Creatur.Genetics.BRGCWord16- ALife.Creatur.Genetics.Diploid- ALife.Creatur.Genetics.Recombination- ALife.Creatur.Genetics.Reproduction.Sexual- ALife.Creatur.Genetics.Reproduction.SimplifiedSexual- ALife.Creatur.Logger- ALife.Creatur.Logger.SimpleLogger- ALife.Creatur.Logger.SimpleRotatingLogger- ALife.Creatur.Namer- ALife.Creatur.Persistent- ALife.Creatur.Universe- ALife.Creatur.Task- ALife.Creatur.Util- build-depends:- array >=0.5.2.0 && <0.6,- base >=4.10.0.0 && <4.11,- binary >=0.8.5.1 && <0.9,- bytestring >=0.10.8.2 && <0.11,- cond >=0.4.1.1 && <0.5,- cereal >=0.5.4.0 && <0.6,- directory >=1.3.0.2 && <1.4,- exceptions >=0.8.3 && <0.9,- filepath >=1.4.1.2 && <1.5,- gray-extended >=1.5.2 && <1.6,- hdaemonize >=0.5.4 && <0.6,- hsyslog >=5.0.1 && <5.1,- MonadRandom >=0.5.1 && <0.6,- mtl >=2.2.1 && <2.3,- old-locale >=1.0.0.7 && <1.1,- process >=1.6.1.0 && <1.7,- random ==1.1.*,- split >=0.2.3.2 && <0.3,- time >=1.8.0.2 && <1.9,- transformers >=0.5.2.0 && <0.6,- unix >=2.7.2.2 && <2.8,- zlib >=0.6.1.2 && <0.7- hs-source-dirs: src- other-modules:- Paths_creatur- ghc-options: -Wall -fno-warn-orphans+name: creatur+version: 5.9.25+synopsis: Framework for artificial life experiments.+description: Please see the README on GitHub at <https://github.com/mhwombat/creatur#readme>+category: AI+homepage: https://github.com/mhwombat/creatur#readme+bug-reports: https://github.com/mhwombat/creatur/issues+author: Amy de Buitléir+maintainer: amy@nualeargais.ie+copyright: 2018 Amy de Buitléir+license: BSD3+license-file: LICENSE+build-type: Simple+cabal-version: >= 1.10+extra-source-files:+ ChangeLog.md+ README.md -test-suite creatur-tests- type: exitcode-stdio-1.0- main-is: TestAll.hs- build-depends:- array >=0.5.2.0 && <0.6,- base >=4.10.0.0 && <4.11,- binary >=0.8.5.1 && <0.9,- cereal >=0.5.4.0 && <0.6,- creatur,- directory >=1.3.0.2 && <1.4,- filepath >=1.4.1.2 && <1.5,- hsyslog >=5.0.1 && <5.1,- HUnit >=1.6.0.0 && <1.7,- MonadRandom >=0.5.1 && <0.6,- mtl >=2.2.1 && <2.3,- temporary >=1.2.1.1 && <1.3,- test-framework >=0.8.1.1 && <0.9,- test-framework-hunit >=0.3.0.2 && <0.4,- test-framework-quickcheck2 >=0.3.0.4 && <0.4,- QuickCheck >=2.10.0.1 && <2.11- hs-source-dirs: test- other-modules:- ALife.Creatur.ChecklistQC- ALife.Creatur.CounterQC- ALife.Creatur.Database.CachedFileSystemQC- ALife.Creatur.Database.FileSystemQC- ALife.Creatur.Genetics.BRGCBoolQC- ALife.Creatur.Genetics.BRGCWord16QC- ALife.Creatur.Genetics.BRGCWord8QC- ALife.Creatur.Genetics.DiploidQC- ALife.Creatur.Genetics.RecombinationQC- ALife.Creatur.PersistentQC- ALife.Creatur.UniverseQC- ALife.Creatur.UtilQC- ghc-options: -Wall+source-repository head+ type: git+ location: https://github.com/mhwombat/creatur +library+ exposed-modules:+ ALife.Creatur+ ALife.Creatur.Checklist+ ALife.Creatur.Clock+ ALife.Creatur.Counter+ ALife.Creatur.Daemon+ ALife.Creatur.Database+ ALife.Creatur.Database.CachedFileSystem+ ALife.Creatur.Database.CachedFileSystemInternal+ ALife.Creatur.Database.FileSystem+ ALife.Creatur.Genetics.Analysis+ ALife.Creatur.Genetics.BRGCBool+ ALife.Creatur.Genetics.BRGCWord16+ ALife.Creatur.Genetics.BRGCWord8+ ALife.Creatur.Genetics.Diploid+ ALife.Creatur.Genetics.Recombination+ ALife.Creatur.Genetics.Reproduction.Sexual+ ALife.Creatur.Genetics.Reproduction.SimplifiedSexual+ ALife.Creatur.Logger+ ALife.Creatur.Logger.SimpleLogger+ ALife.Creatur.Logger.SimpleRotatingLogger+ ALife.Creatur.Namer+ ALife.Creatur.Persistent+ ALife.Creatur.Task+ ALife.Creatur.Universe+ ALife.Creatur.Util+ other-modules:+ Paths_creatur+ hs-source-dirs:+ src+ build-depends:+ MonadRandom+ , array+ , base >=4.7 && <5+ , binary+ , bytestring+ , cereal+ , cond+ , directory+ , exceptions+ , filepath+ , gray-extended+ , hdaemonize+ , hsyslog+ , mtl+ , random+ , split+ , time+ , transformers+ , unix+ default-language: Haskell2010 --- Benchmark creatur-bench--- Type: exitcode-stdio-1.0--- Main-is: BenchAll.hs--- GHC-Options: -Wall--- Hs-source-dirs: test--- Build-Depends:--- base,--- creatur,--- criterion,--- test-framework--- Other-modules: ALife.Creatur.Genetics.BRGCWord8Bench+test-suite creatur-test+ type: exitcode-stdio-1.0+ main-is: Spec.hs+ other-modules:+ ALife.Creatur.ChecklistQC+ ALife.Creatur.CounterQC+ ALife.Creatur.Database.CachedFileSystemQC+ ALife.Creatur.Database.FileSystemQC+ ALife.Creatur.Genetics.BRGCBoolQC+ ALife.Creatur.Genetics.BRGCWord16QC+ ALife.Creatur.Genetics.BRGCWord8QC+ ALife.Creatur.Genetics.DiploidQC+ ALife.Creatur.Genetics.RecombinationQC+ ALife.Creatur.PersistentQC+ ALife.Creatur.UniverseQC+ ALife.Creatur.UtilQC+ Paths_creatur+ hs-source-dirs:+ test+ ghc-options: -threaded -rtsopts -with-rtsopts=-N+ build-depends:+ HUnit+ , MonadRandom+ , QuickCheck+ , base >=4.7 && <5+ , cereal+ , creatur+ , directory+ , filepath+ , mtl+ , temporary+ , test-framework+ , test-framework-hunit+ , test-framework-quickcheck2+ default-language: Haskell2010
src/ALife/Creatur.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Checklist.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Checklist--- Copyright : (c) Amy de Buitléir 2013-2017+-- Copyright : (c) Amy de Buitléir 2013-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Clock.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Clock--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Counter.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Counter--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Daemon.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Daemon--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental@@ -24,16 +24,16 @@ requestShutdown ) where -import Control.Concurrent (MVar, newMVar, readMVar, swapMVar, +import Control.Concurrent (MVar, newMVar, readMVar, swapMVar, threadDelay) import Control.Exception (SomeException, handle, catch) import Control.Monad (when) import Control.Monad.State (StateT, execStateT) import Foreign.C.String (withCStringLen)-import System.IO (hPutStr, stderr)+import System.IO (hPutStr, hPutStrLn, stderr) import System.IO.Unsafe (unsafePerformIO) import qualified System.Posix.Daemonize as D-import System.Posix.Signals (Handler(Catch), fullSignalSet, +import System.Posix.Signals (Handler(Catch), fullSignalSet, installHandler, sigTERM) import System.Posix.Syslog (Priority(Warning), Facility(Daemon), syslog) import System.Posix.User (getLoginName, getRealUserID)@@ -66,12 +66,13 @@ -- the login name. simpleDaemon :: Job s -> s -> D.CreateDaemon () simpleDaemon j s = D.simpleDaemon { D.program = daemonMain j s,- D.user = Just "" }+ D.user = Just "",+ D.group = Just ""} -- | @'launch' daemon state@ creates a daemon, which invokes @daemon@. -- *Note:* If @'user'@ (in @'daemon'@) is @Just ""@, the daemon will -- run under the login name. If @'user'@ is Nothing, the daemon will--- run under the name of the executable file containing the daemon. +-- run under the name of the executable file containing the daemon. launch :: CreaturDaemon p s -> IO () launch d = do uid <- getRealUserID@@ -79,8 +80,16 @@ then putStrLn "Must run as root" else do u <- defaultToLoginName (D.user . daemon $ d)- D.serviced $ (daemon d) { D.user = u }+ g <- defaultToLoginName (D.user . daemon $ d)+ let d' = (daemon d) { D.user = u, D.group = g }+ catch (D.serviced d') handleLaunchError +handleLaunchError :: SomeException -> IO ()+handleLaunchError e = do+ let err = show (e :: SomeException)+ hPutStrLn stderr ("Warning: Couldn't launch daemon: " ++ err)+ return ()+ launchInteractive :: Job s -> s -> IO () launchInteractive j s = do s' <- onStartup j s@@ -114,7 +123,7 @@ (\e -> do let err = show (e :: SomeException) withCStringLen ("Unhandled exception: " ++ err) $ syslog (Just Daemon) Warning- hPutStr stderr ("Unhandled exception: " ++ err)+ hPutStrLn stderr ("Unhandled exception: " ++ err) return ()) requestShutdown :: IO ()
src/ALife/Creatur/Database.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Database--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Database/CachedFileSystem.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Database.CachedFileSystem--- Copyright : (c) Amy de Buitléir 2014-2017+-- Copyright : (c) Amy de Buitléir 2014-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Database/CachedFileSystemInternal.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Database.CachedFileSystemInternal--- Copyright : (c) Amy de Buitléir 2014-2017+-- Copyright : (c) Amy de Buitléir 2014-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Database/FileSystem.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Database.FileSystem--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Genetics/Analysis.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Genetics.Analysis--- Copyright : (c) Amy de Buitléir 2013-2017+-- Copyright : (c) Amy de Buitléir 2013-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Genetics/BRGCBool.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Genetics.BRGCBool--- Copyright : (c) Amy de Buitléir 2013-2017+-- Copyright : (c) Amy de Buitléir 2013-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Genetics/BRGCWord16.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Genetics.BRGCWord16--- Copyright : (c) Amy de Buitléir 2014-2017+-- Copyright : (c) Amy de Buitléir 2014-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Genetics/BRGCWord8.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Genetics.BRGCWord8--- Copyright : (c) Amy de Buitléir 2013-2017+-- Copyright : (c) Amy de Buitléir 2013-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Genetics/Diploid.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Genetics.Diploid--- Copyright : (c) Amy de Buitléir 2013-2017+-- Copyright : (c) Amy de Buitléir 2013-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Genetics/Recombination.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Genetics.Recombination--- Copyright : (c) Amy de Buitléir 2011-2017+-- Copyright : (c) Amy de Buitléir 2011-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Genetics/Reproduction/Sexual.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Genetics.Reproduction.Sexual--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Genetics/Reproduction/SimplifiedSexual.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Genetics.Reproduction.SimplifiedSexual--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Logger.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Logger--- Copyright : (c) Amy de Buitléir 2011-2017+-- Copyright : (c) Amy de Buitléir 2011-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Logger/SimpleLogger.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Logger.SimpleLogger--- Copyright : (c) Amy de Buitléir 2011-2017+-- Copyright : (c) Amy de Buitléir 2011-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Logger/SimpleRotatingLogger.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Logger.SimpleRotatingLogger--- Copyright : (c) Amy de Buitléir 2011-2017+-- Copyright : (c) Amy de Buitléir 2011-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Namer.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Namer--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Persistent.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Persistent--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Task.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Task--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Universe.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Universe--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
src/ALife/Creatur/Util.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Util--- Copyright : (c) Amy de Buitléir 2011-2017+-- Copyright : (c) Amy de Buitléir 2011-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental@@ -59,13 +59,13 @@ let l = length xs rands <- take l `fmap` getRandomRs (0, l-1) let ar = runSTArray $ do- ar' <- thawSTArray $ listArray (0, l-1) xs- forM_ (zip [0..(l-1)] rands) $ \(i, j) -> do- vi <- readSTArray ar' i- vj <- readSTArray ar' j- writeSTArray ar' j vi- writeSTArray ar' i vj- return ar'+ ar' <- thawSTArray $ listArray (0, l-1) xs+ forM_ (zip [0..(l-1)] rands) $ \(i, j) -> do+ vi <- readSTArray ar' i+ vj <- readSTArray ar' j+ writeSTArray ar' j vi+ writeSTArray ar' i vj+ return ar' return (elems ar) -- | @'safeReplaceElement' xs n x@ returns a copy of @xs@ in which the @n@th@@ -80,7 +80,7 @@ -- element has been replaced with @x@. Causes an exception if @xs@ has -- fewer than @n+1@ elements. Compare with @'safeReplaceElement'@. replaceElement :: [a] -> Int -> a -> [a]-replaceElement xs i x = +replaceElement xs i x = if 0 <= i && i < length xs then fore ++ (x : aft) else xs where fore = take i xs aft = drop (i+1) xs@@ -105,7 +105,7 @@ -- @'cropSquare' 3 [\'a\'..\'y\']@ returns. cropSquare :: Int -> [a] -> [a] cropSquare n xs | n <= 0 = []- | n < m = + | n < m = cropRect (margin, margin) (margin+n-1, margin+n-1) xs m | otherwise = take (m*m) xs where m = (isqrt . length) xs@@ -152,13 +152,13 @@ where n' = fromIntegral n :: Float m' = fromIntegral m :: Float --- | @'perfectSquare' n@ returns @True@ if @n@ is a perfect square (i.e., if +-- | @'perfectSquare' n@ returns @True@ if @n@ is a perfect square (i.e., if -- there exists an _integer_ m such that m*m = n) perfectSquare :: Integral a => a -> Bool perfectSquare n = n == m*m where m = isqrt n --- | @n 'isPowerOf' m@ returns @True@ if @n@ is a power of m (i.e., if +-- | @n 'isPowerOf' m@ returns @True@ if @n@ is a power of m (i.e., if -- there exists an _integer_ k such that m^k = n) isPowerOf :: Integral a => a -> a -> Bool isPowerOf n m = n == m^k@@ -180,20 +180,20 @@ fromEither d x = case x of {Left _ -> d; Right v -> v} -- | Takes a list of 'Either's and returns a list of all the 'Right'--- values. +-- values. catEithers :: [Either e a] -> [a] catEithers ls = [x | Right x <- ls] -- | Like modify, but the function that maps the old state to the -- new state operates in the inner monad. -- For example,--- +-- -- > s <- get -- > s' = lift $ f s -- > put s'--- +-- -- can be replaced with--- +-- -- > modifyLift f modifyLift :: Monad m => (s -> m s) -> StateT s m () modifyLift f = get >>= lift . f >>= put@@ -203,12 +203,12 @@ -- Similar to modifyLift, but the function being invoked doesn't -- have a return value, so the state is not modified. -- For example,--- +-- -- > s <- get -- > s' = lift $ f s--- +-- -- can be replaced with--- +-- -- > getLift f getLift :: Monad m => (s -> m ()) -> StateT s m () getLift f = get >>= lift . f >> return ()
test/ALife/Creatur/ChecklistQC.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.ChecklistQC--- Copyright : (c) Amy de Buitléir 2013-2017+-- Copyright : (c) Amy de Buitléir 2013-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
test/ALife/Creatur/CounterQC.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.CounterQC--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
test/ALife/Creatur/Database/CachedFileSystemQC.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Database.CachedFileSystemQC--- Copyright : (c) Amy de Buitléir 2014-2017+-- Copyright : (c) Amy de Buitléir 2014-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
test/ALife/Creatur/Database/FileSystemQC.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Database.FileSystemQC--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
test/ALife/Creatur/Genetics/BRGCBoolQC.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Genetics.BRGCBoolQC--- Copyright : (c) Amy de Buitléir 2013-2017+-- Copyright : (c) Amy de Buitléir 2013-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
test/ALife/Creatur/Genetics/BRGCWord16QC.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Genetics.BRGCWord16QC--- Copyright : (c) Amy de Buitléir 2014-2017+-- Copyright : (c) Amy de Buitléir 2014-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
test/ALife/Creatur/Genetics/BRGCWord8QC.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Genetics.BRGCWord8QC--- Copyright : (c) Amy de Buitléir 2013-2017+-- Copyright : (c) Amy de Buitléir 2013-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
test/ALife/Creatur/Genetics/DiploidQC.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Genetics.DiploidQC--- Copyright : (c) Amy de Buitléir 2013-2017+-- Copyright : (c) Amy de Buitléir 2013-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
test/ALife/Creatur/Genetics/RecombinationQC.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.Genetics.RecombinationQC--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
test/ALife/Creatur/PersistentQC.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.PersistentQC--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
test/ALife/Creatur/UniverseQC.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.UniverseQC--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
test/ALife/Creatur/UtilQC.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- | -- Module : ALife.Creatur.UtilQC--- Copyright : (c) Amy de Buitléir 2012-2017+-- Copyright : (c) Amy de Buitléir 2012-2018 -- License : BSD-style -- Maintainer : amy@nualeargais.ie -- Stability : experimental
+ test/Spec.hs view
@@ -0,0 +1,49 @@+------------------------------------------------------------------------+-- |+-- Module : Main+-- Copyright : (c) Amy de Buitléir 2012-2018+-- License : BSD-style+-- Maintainer : amy@nualeargais.ie+-- Stability : experimental+-- Portability : portable+--+-- Runs the QuickCheck tests.+--+------------------------------------------------------------------------+module Main where++import ALife.Creatur.CounterQC (test)+import ALife.Creatur.ChecklistQC (test)+import ALife.Creatur.UniverseQC (test)+import ALife.Creatur.Database.FileSystemQC (test)+import ALife.Creatur.Database.CachedFileSystemQC (test)+import ALife.Creatur.Genetics.DiploidQC (test)+import ALife.Creatur.Genetics.RecombinationQC (test)+import ALife.Creatur.Genetics.BRGCBoolQC (test)+import ALife.Creatur.Genetics.BRGCWord8QC (test)+import ALife.Creatur.Genetics.BRGCWord16QC (test)+import ALife.Creatur.PersistentQC (test)+import ALife.Creatur.UtilQC (test)++import Test.Framework as TF (defaultMain, Test)++tests :: [TF.Test]+tests = + [+ -- Tests are in order of increasing complexity+ ALife.Creatur.PersistentQC.test,+ ALife.Creatur.CounterQC.test,+ ALife.Creatur.ChecklistQC.test,+ ALife.Creatur.UniverseQC.test,+ ALife.Creatur.Database.FileSystemQC.test,+ ALife.Creatur.Database.CachedFileSystemQC.test,+ ALife.Creatur.UtilQC.test,+ ALife.Creatur.Genetics.DiploidQC.test,+ ALife.Creatur.Genetics.RecombinationQC.test,+ ALife.Creatur.Genetics.BRGCBoolQC.test,+ ALife.Creatur.Genetics.BRGCWord8QC.test,+ ALife.Creatur.Genetics.BRGCWord16QC.test+ ]++main :: IO ()+main = defaultMain tests
− test/TestAll.hs
@@ -1,49 +0,0 @@---------------------------------------------------------------------------- |--- Module : Main--- Copyright : (c) Amy de Buitléir 2012-2017--- License : BSD-style--- Maintainer : amy@nualeargais.ie--- Stability : experimental--- Portability : portable------ Runs the QuickCheck tests.-----------------------------------------------------------------------------module Main where--import ALife.Creatur.CounterQC (test)-import ALife.Creatur.ChecklistQC (test)-import ALife.Creatur.UniverseQC (test)-import ALife.Creatur.Database.FileSystemQC (test)-import ALife.Creatur.Database.CachedFileSystemQC (test)-import ALife.Creatur.Genetics.DiploidQC (test)-import ALife.Creatur.Genetics.RecombinationQC (test)-import ALife.Creatur.Genetics.BRGCBoolQC (test)-import ALife.Creatur.Genetics.BRGCWord8QC (test)-import ALife.Creatur.Genetics.BRGCWord16QC (test)-import ALife.Creatur.PersistentQC (test)-import ALife.Creatur.UtilQC (test)--import Test.Framework as TF (defaultMain, Test)--tests :: [TF.Test]-tests = - [- -- Tests are in order of increasing complexity- ALife.Creatur.PersistentQC.test,- ALife.Creatur.CounterQC.test,- ALife.Creatur.ChecklistQC.test,- ALife.Creatur.UniverseQC.test,- ALife.Creatur.Database.FileSystemQC.test,- ALife.Creatur.Database.CachedFileSystemQC.test,- ALife.Creatur.UtilQC.test,- ALife.Creatur.Genetics.DiploidQC.test,- ALife.Creatur.Genetics.RecombinationQC.test,- ALife.Creatur.Genetics.BRGCBoolQC.test,- ALife.Creatur.Genetics.BRGCWord8QC.test,- ALife.Creatur.Genetics.BRGCWord16QC.test- ]--main :: IO ()-main = defaultMain tests