modelling-tasks-0.0.0.1
Safe HaskellSafe-Inferred
LanguageHaskell2010

Modelling.Auxiliary.Common

Synopsis

Documentation

data Object Source #

Constructors

Object 

Fields

Instances

Instances details
Show Object Source # 
Instance details

Defined in Modelling.Auxiliary.Common

Eq Object Source # 
Instance details

Defined in Modelling.Auxiliary.Common

Methods

(==) :: Object -> Object -> Bool #

(/=) :: Object -> Object -> Bool #

Ord Object Source # 
Instance details

Defined in Modelling.Auxiliary.Common

class Randomise a where Source #

The class of types that allow some form of randomisation.

Minimal complete definition

randomise

Methods

randomise :: (MonadRandom m, MonadThrow m) => a -> m a Source #

Shuffles every component without affecting basic overall properties

isRandomisable :: a -> Maybe String Source #

Checks the randomisability of the given value * returns Nothing, if it is randomisable * returns Just the explanation why not, otherwise

class RandomiseLayout a where Source #

The class of types that allow changing its layout randomly.

Methods

randomiseLayout :: (MonadRandom m, MonadThrow m) => a -> m a Source #

class RandomiseNames a where Source #

The class of types that allow swapping (some of) its components names randomly.

Minimal complete definition

randomiseNames

Methods

hasRandomisableNames :: a -> Maybe String Source #

Checks the randomisability of names for the given value * returns Nothing, if it is randomisable * returns Just the explanation why not, otherwise

randomiseNames :: (MonadRandom m, MonadThrow m) => a -> m a Source #

Shuffles the order of names of an instance, swapping names of components

newtype ShuffleExcept g a Source #

Constructors

ShuffleExcept 

Fields

Instances

Instances details
RandomGen g => MonadRandom (ShuffleExcept g) Source # 
Instance details

Defined in Modelling.Auxiliary.Common

Methods

getRandomR :: Random a => (a, a) -> ShuffleExcept g a

getRandom :: Random a => ShuffleExcept g a

getRandomRs :: Random a => (a, a) -> ShuffleExcept g [a]

getRandoms :: Random a => ShuffleExcept g [a]

Applicative (ShuffleExcept g) Source # 
Instance details

Defined in Modelling.Auxiliary.Common

Methods

pure :: a -> ShuffleExcept g a #

(<*>) :: ShuffleExcept g (a -> b) -> ShuffleExcept g a -> ShuffleExcept g b #

liftA2 :: (a -> b -> c) -> ShuffleExcept g a -> ShuffleExcept g b -> ShuffleExcept g c #

(*>) :: ShuffleExcept g a -> ShuffleExcept g b -> ShuffleExcept g b #

(<*) :: ShuffleExcept g a -> ShuffleExcept g b -> ShuffleExcept g a #

Functor (ShuffleExcept g) Source # 
Instance details

Defined in Modelling.Auxiliary.Common

Methods

fmap :: (a -> b) -> ShuffleExcept g a -> ShuffleExcept g b #

(<$) :: a -> ShuffleExcept g b -> ShuffleExcept g a #

Monad (ShuffleExcept g) Source # 
Instance details

Defined in Modelling.Auxiliary.Common

Methods

(>>=) :: ShuffleExcept g a -> (a -> ShuffleExcept g b) -> ShuffleExcept g b #

(>>) :: ShuffleExcept g a -> ShuffleExcept g b -> ShuffleExcept g b #

return :: a -> ShuffleExcept g a #

MonadThrow (ShuffleExcept g) Source # 
Instance details

Defined in Modelling.Auxiliary.Common

Methods

throwM :: Exception e => e -> ShuffleExcept g a #

findFittingRandomElements Source #

Arguments

:: MonadRandom m 
=> Bool

useDifferentElements flag

-> [a]

available elements

-> [a -> m Bool]

predicates to satisfy

-> m (Maybe [a]) 

Find fitting random elements with sophisticated distribution logic Tries valid divisors in descending order with retry mechanism for each divisor

getFirstInstance :: MonadThrow m => [a] -> m a Source #

lensRulesL :: LensRules Source #

mapIndicesTo :: (Eq a, MonadThrow m) => [a] -> [a] -> m [(Int, Int)] Source #

oneOf :: MonadRandom m => [a] -> m a Source #

parseWith :: MonadThrow m => (Int -> Parser a) -> String -> m a Source #

toMap :: (Ord a, Ord b) => Set (a, b) -> Map a (Set b) Source #

weightedShuffle :: (MonadRandom m, Eq a, Real w) => [(a, w)] -> m [a] Source #

Shuffle a list of elements from type a based on given weights of type w, where higher weight indicates a bigger probability of the element occurring at a lower index of the list. The total weight of all elements must not be zero.

Orphan instances

MonadThrow m => MonadThrow (RandT g m) Source # 
Instance details

Methods

throwM :: Exception e => e -> RandT g m a #