The candidate network edges function makes use of vectors written in the form of openly recursive 'memoized producers'. That is, they are given as types defined as follows (in Data.Vector.Utility):
newtype DVector a = DVector {getDVector :: (Int -> a) -> Int -> a}
From a DVector one can then produce a memoized vector. We should factor out the memoization used in postorderSequence' (defined in Bio.Graph.PhylogeneticDAG.Postorder) and preorderSequence (defined in Bio.Graph.PhylogeneticDAG.Preorder) to make use of this new type. For any cached data that these functions make use of we should write the functions that collect this data (largely defined in Bio.Graph.ReferenceDAG.Internal) in the form of a DVector which is to be consumed by the postorder or preorder.
With the DVector type it may be worth thinking about adding custom rules as in this toy example: https://gist.github.com/Boarders/10d5697fd32dc21b0fe0219cea239f80
It is worth researching how best to write these rules to allow for further fusion optimisation if this is relevant and otherwise simply a way to not produce an intermediate data structure.
The candidate network edges function makes use of vectors written in the form of openly recursive 'memoized producers'. That is, they are given as types defined as follows (in
Data.Vector.Utility
):newtype DVector a = DVector {getDVector :: (Int -> a) -> Int -> a}
From a DVector one can then produce a memoized vector. We should factor out the memoization used in postorderSequence' (defined in
Bio.Graph.PhylogeneticDAG.Postorder
) and preorderSequence (defined inBio.Graph.PhylogeneticDAG.Preorder
) to make use of this new type. For anycached
data that these functions make use of we should write the functions that collect this data (largely defined inBio.Graph.ReferenceDAG.Internal
) in the form of a DVector which is to be consumed by the postorder or preorder.With the DVector type it may be worth thinking about adding custom rules as in this toy example: https://gist.github.com/Boarders/10d5697fd32dc21b0fe0219cea239f80 It is worth researching how best to write these rules to allow for further fusion optimisation if this is relevant and otherwise simply a way to not produce an intermediate data structure.