packages feed

creatur 5.9.8.2 → 5.9.9

raw patch · 3 files changed

+44/−15 lines, 3 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

+ ALife.Creatur.Genetics.BRGCWord8: instance ALife.Creatur.Genetics.BRGCWord8.Genetic GHC.Word.Word32
+ ALife.Creatur.Genetics.BRGCWord8: instance ALife.Creatur.Genetics.BRGCWord8.Genetic GHC.Word.Word64

Files

creatur.cabal view
@@ -1,5 +1,5 @@ Name:              creatur-Version:           5.9.8.2+Version:           5.9.9 Stability:         experimental Synopsis:          Framework for artificial life experiments. Description:       A software framework for automating experiments@@ -36,7 +36,7 @@ source-repository this   type:     git   location: https://github.com/mhwombat/creatur.git-  tag:      5.9.8.2+  tag:      5.9.9  library   GHC-Options:      -Wall -fno-warn-orphans@@ -70,7 +70,7 @@   Other-modules:    Paths_creatur   Build-Depends:                     array ==0.5.*,-                    base ==4.*,+                    base ==4.* && >= 4.8,                     bytestring ==0.10.*,                     cond ==0.4.*,                     cereal ==0.4.*,@@ -98,7 +98,7 @@   Hs-source-dirs:   test   Build-Depends:                     array ==0.5.*,-                    base ==4.*,+                    base ==4.* && >= 4.8,                     binary ==0.7.*,                     cereal ==0.4.*,                     creatur,@@ -135,7 +135,7 @@ --   GHC-Options:      -Wall --   Hs-source-dirs:   test --   Build-Depends:---                     base ==4.*,+--                     base ==4.* && >= 4.8, --                     creatur, --                     criterion ==0.8.*, --                     test-framework ==0.8.*
src/ALife/Creatur/Genetics/BRGCWord8.hs view
@@ -65,7 +65,7 @@ import Data.Char (ord, chr) import Data.Either (partitionEithers) import Data.Functor.Identity (Identity)-import Data.Word (Word8, Word16)+import Data.Word (Word8, Word16, Word32, Word64) import GHC.Generics  #if MIN_VERSION_base(4,8,0)@@ -205,18 +205,43 @@           convert _ = Left "logic error"  instance Genetic Word16 where-  put g = putAndReport-            [fromIntegral $ x `div` 0x100, fromIntegral $ x `mod` 0x100]-              (show g ++ " Word16")+  put g = putAndReport (integralToBytes 2 x) (show g ++ " Word16")     where x = integralToGray g   get = getAndReport 2 grayWord16 +instance Genetic Word32 where+  put g = putAndReport (integralToBytes 4 x) (show g ++ " Word32")+    where x = integralToGray g+  get = getAndReport 4 grayWord32++instance Genetic Word64 where+  put g = putAndReport (integralToBytes 8 x) (show g ++ " Word64")+    where x = integralToGray g+  get = getAndReport 8 grayWord64+ grayWord16 :: [Word8] -> Either String (Word16, String)-grayWord16 (x:y:[]) = Right (g, show g ++ " Word16")-  where g = grayToIntegral (high + low) :: Word16-        high = fromIntegral x * 0x100-        low = fromIntegral y-grayWord16 _ = Left "logic error"+grayWord16 bs = Right (g, show g ++ " Word16")+  where g = grayToIntegral . bytesToIntegral $ bs++grayWord32 :: [Word8] -> Either String (Word32, String)+grayWord32 bs = Right (g, show g ++ " Word32")+  where g = grayToIntegral . bytesToIntegral $ bs++grayWord64 :: [Word8] -> Either String (Word64, String)+grayWord64 bs = Right (g, show g ++ " Word64")+  where g = grayToIntegral . bytesToIntegral $ bs++integralToBytes :: Integral t => Int -> t -> [Word8]+integralToBytes n x = f n x []+  where f 0 _ bs = bs+        f m y bs = f (m-1) y' (b:bs)+          where y' = y `div` 0x100+                b = fromIntegral $ y `mod` 0x100+ +bytesToIntegral :: Integral t => [Word8] -> t+bytesToIntegral bs = f (bs, 0)+  where f ([], n) = n+        f (k:ks, n) = f (ks, n*0x100 + fromIntegral k)  instance (Genetic a) => Genetic [a] where   put xs = do
test/ALife/Creatur/Genetics/BRGCWord8QC.hs view
@@ -22,7 +22,7 @@ import ALife.Creatur.Genetics.BRGCWord8 import ALife.Creatur.Genetics.Analysis (Analysable) import ALife.Creatur.Util (fromEither)-import Data.Word (Word8, Word16)+import Data.Word (Word8, Word16, Word32, Word64) import GHC.Generics (Generic) import Test.Framework as TF (Test, testGroup) import Test.Framework.Providers.QuickCheck2 (testProperty)@@ -80,6 +80,10 @@       (prop_round_trippable :: Word8 -> Property),     testProperty "prop_round_trippable - Word16"       (prop_round_trippable :: Word16 -> Property),+    testProperty "prop_round_trippable - Word32"+      (prop_round_trippable :: Word32 -> Property),+    testProperty "prop_round_trippable - Word64"+      (prop_round_trippable :: Word64 -> Property),     testProperty "prop_round_trippable - TestStructure"       (prop_round_trippable :: TestStructure -> Property),     testProperty "prop_rawWord8s_round_trippable"