Skip to content

Commit

Permalink
added assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
mhwombat committed Jun 23, 2016
1 parent da18995 commit e61c055
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
11 changes: 1 addition & 10 deletions creatur.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: creatur
Version: 5.9.12
Version: 5.9.13
Stability: experimental
Synopsis: Framework for artificial life experiments.
Description: A software framework for automating experiments
Expand Down Expand Up @@ -29,15 +29,6 @@ Maintainer: [email protected]
Build-Type: Simple
Cabal-Version: >=1.8

source-repository head
type: git
location: https://github.com/mhwombat/creatur.git

source-repository this
type: git
location: https://github.com/mhwombat/creatur.git
tag: 5.9.10

library
GHC-Options: -Wall -fno-warn-orphans
Hs-source-dirs: src
Expand Down
3 changes: 2 additions & 1 deletion src/ALife/Creatur/Genetics/Recombination.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module ALife.Creatur.Genetics.Recombination
import ALife.Creatur.Util (safeReplaceElement)

import System.Random (Random)
import Control.Exception.Base (assert)
import Control.Monad.Random (Rand, RandomGen, getRandom, getRandomR)

-- | Cuts two lists at the specified locations, swaps the ends, and
Expand Down Expand Up @@ -166,7 +167,7 @@ randomOneOfList xs = do
-- | Choose an element at random from a list and return the element and its
-- index
randomListSelection :: RandomGen g => [a] -> Rand g (Int, a)
randomListSelection xs = do
randomListSelection xs = assert (not . null $ xs) $ do
i <- getRandomR (0,length xs - 1)
return (i, xs !! i)

0 comments on commit e61c055

Please sign in to comment.