Copyright | (c) Fabricio Olivetti 2021 - 2021 |
---|---|
License | BSD3 |
Maintainer | fabricio.olivetti@gmail.com |
Stability | experimental |
Portability | ConstraintKinds |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Functions to generate random trees and nodes.
Synopsis
- class HasVars p
- class HasVals p
- class HasFuns p
- type HasEverything p = (HasVars p, HasVals p, HasExps p, HasFuns p)
- data FullParams ix val = P [ix] (val, val) (Int, Int) [Function]
- type RndTree p ix val = ReaderT (p ix val) (StateT StdGen IO) (SRTree ix val)
- randomVar :: HasVars p => RndTree p ix val
- randomConst :: (Ord val, Random val, HasVals p) => RndTree p ix val
- randomPow :: (Ord val, Random val, HasExps p) => RndTree p ix val
- randomFunction :: HasFuns p => RndTree p ix val
- randomNode :: (Ord val, Random val, HasEverything p) => RndTree p ix val
- randomNonTerminal :: (Ord val, Random val, HasEverything p) => RndTree p ix val
- randomTree :: (Ord val, Random val, HasEverything p) => Int -> RndTree p ix val
- randomTreeBalanced :: (Ord val, Random val, HasEverything p) => Int -> RndTree p ix val
Documentation
_vars
Instances
HasVars FullParams Source # | |
Defined in Data.SRTree.Random _vars :: FullParams ix val -> [ix] |
_range
Instances
HasVals FullParams Source # | |
Defined in Data.SRTree.Random _range :: FullParams ix val -> (val, val) |
_funs
Instances
HasFuns FullParams Source # | |
Defined in Data.SRTree.Random _funs :: FullParams ix val -> [Function] |
type HasEverything p = (HasVars p, HasVals p, HasExps p, HasFuns p) Source #
Constraint synonym for all properties.
data FullParams ix val Source #
A structure with every property
Instances
HasFuns FullParams Source # | |
Defined in Data.SRTree.Random _funs :: FullParams ix val -> [Function] | |
HasVals FullParams Source # | |
Defined in Data.SRTree.Random _range :: FullParams ix val -> (val, val) | |
HasVars FullParams Source # | |
Defined in Data.SRTree.Random _vars :: FullParams ix val -> [ix] |
type RndTree p ix val = ReaderT (p ix val) (StateT StdGen IO) (SRTree ix val) Source #
RndTree is a Monad Transformer to generate random trees of type `SRTree ix val`
given the parameters `p ix val` using the random number generator StdGen
.
randomVar :: HasVars p => RndTree p ix val Source #
Returns a random variable, the parameter p
must have the HasVars
property
randomConst :: (Ord val, Random val, HasVals p) => RndTree p ix val Source #
Returns a random constant, the parameter p
must have the HasConst
property
randomPow :: (Ord val, Random val, HasExps p) => RndTree p ix val Source #
Returns a random integer power node, the parameter p
must have the HasExps
property
randomFunction :: HasFuns p => RndTree p ix val Source #
Returns a random function, the parameter p
must have the HasFuns
property
randomNode :: (Ord val, Random val, HasEverything p) => RndTree p ix val Source #
Returns a random node, the parameter p
must have every property.
randomNonTerminal :: (Ord val, Random val, HasEverything p) => RndTree p ix val Source #
Returns a random non-terminal node, the parameter p
must have every property.
randomTree :: (Ord val, Random val, HasEverything p) => Int -> RndTree p ix val Source #
Returns a random tree with a limited budget, the parameter p
must have every property.
randomTreeBalanced :: (Ord val, Random val, HasEverything p) => Int -> RndTree p ix val Source #
Returns a random tree with a approximately a number n
of nodes, the parameter p
must have every property.