Safe Haskell | None |
---|
Operation and interface for Genes
- module Data.Tree
- module System.Random
- genEukarya :: (RandomGen g, HeukaryaGene d) => g -> Int -> Text -> [d] -> Tree d
- crossEukarya :: (RandomGen g, HeukaryaGene d) => g -> Int -> (Tree d, Tree d) -> (Tree d, Tree d)
- mutateEukarya :: (RandomGen g, HeukaryaGene d) => g -> Int -> [d] -> Tree d -> Tree d
- class (NFData d, Show d) => HeukaryaGene d where
- evalTreeGene :: Tree d -> d
- geneTypeRep :: d -> Text
- geneHTypes :: d -> [([Text], Text)]
- outputHTreeType :: Tree d -> Text
- instanceOf :: d -> Text -> Text -> Bool
- equalType :: d -> Text -> Text -> Bool
- directType :: d -> Text -> Text -> Bool
- generalizeType :: d -> Text -> Text -> Maybe Text
Documentation
module Data.Tree
module System.Random
Gene Operations
:: (RandomGen g, HeukaryaGene d) | |
=> g | RandomGenerator |
-> Int | depth of tree structure |
-> Text | String representation of output's Type |
-> [d] | Ingredient(Gene) of Eukarya for constructing Eukarya |
-> Tree d |
generate a tree structured Eukarya.
:: (RandomGen g, HeukaryaGene d) | |
=> g | RandomGenerator |
-> Int | depth of tree structure. no functionality here |
-> (Tree d, Tree d) | origin Eukarya pair |
-> (Tree d, Tree d) | crossovered Eukarya pair |
crossover two Eukarya
:: (RandomGen g, HeukaryaGene d) | |
=> g | RandomGenerator |
-> Int | depth of tree structure |
-> [d] | Ingredient(Gene) of Eukarya for mutating Eukarya |
-> Tree d | input Eukarya |
-> Tree d | mutated Eukarya |
mutate Eukarya
Interfaces or Gene implementation
class (NFData d, Show d) => HeukaryaGene d whereSource
Gene's interface
use Text
to represent types
evalTreeGene :: Tree d -> dSource
Transform a syntax tree to a expression
geneTypeRep :: d -> TextSource
Get Gene's Type representation
geneHTypes :: d -> [([Text], Text)]Source
Get every possible input type and output type
>>>
geneHTypes $ toDyn "(+)" ((+)::Int -> Int -> Int)
[([],"Int -> Int -> Int"),(["Int"],"Int -> Int"),(["Int","Int"],"Int")]
outputHTreeType :: Tree d -> TextSource
get tree's actual output type.
instanceOf :: d -> Text -> Text -> BoolSource
the first parameter is just a typeclass indicator that makes which instance to use get whether the former type is the special case of latter type
equalType :: d -> Text -> Text -> BoolSource
the first parameter is just a typeclass indicator that makes which instance to use get whether two types are the same
directType :: d -> Text -> Text -> BoolSource
the first parameter is just a typeclass indicator that makes which instance to use get whether two types have direct relation.
generalizeType :: d -> Text -> Text -> Maybe TextSource
the first parameter is just a typeclass indicator that makes which instance to use return a generalized one if they have direct relation.