amnh / PCG

𝙋𝙝𝙮𝙡𝙤𝙜𝙚𝙣𝙚𝙩𝙞𝙘 𝘾𝙤𝙢𝙥𝙤𝙣𝙚𝙣𝙩 𝙂𝙧𝙖𝙥𝙝 ⸺ Haskell program and libraries for general phylogenetic graph search
28 stars 1 forks source link

Change the postorder and preorder "signatures" to be well typed #77

Closed recursion-ninja closed 5 years ago

recursion-ninja commented 5 years ago

Currently the postorder signature used throughout the code base is : d -> [d'] -> d' It would be better to represent the binary context that gets consumed like so:

data PostOrderBinaryContext d d' 
    = LeafContext d
    | InternalContext d d' d'

Also the preorder signature used throughout the code base is : [d'] -> d -> d' It would be better to represent the binary context that gets consumed like so:

data PreOrderBinaryContext d d' 
    = RootContext d
    | InternalContext d' (Either d d) -- So we know if the current node is the left or right child of the parent

These functions are defined in:

Analysis.Parsimony.Additive.Internal
Analysis.Parsimony.Fitch.Internal
Analysis.Parsimony.Sankoff.Internal
Analysis.Parsimony.Dynamic.DirectOptimization.Internal

The functions are used here:

Bio.Graph.PhylogeneticDAG.Preorder
Bio.Graph.PhylogeneticDAG.Postorder
Bio.Graph.PhylogeneticDAG.DynamicCharacterRerooting
Bio.Graph.PhylogeneticDAG.Internal