-postorder_dfs' :: LastNode l => LGraph m l -> [Block m l]
-postorder_dfs' g@(LGraph _ blocks) =
- let FGraph _ eblock _ = entry g
- in vnode (zip eblock) (\acc _visited -> acc) [] emptyBlockSet
- where
- -- vnode ::
- -- Block m l -> ([Block m l] -> BlockSet -> a) -> [Block m l] -> BlockSet -> a
- vnode block@(Block id _) cont acc visited =
- if elemBlockSet id visited then
- cont acc visited
- else
- vchildren block (get_children block) cont acc (extendBlockSet visited id)
- vchildren block bs cont acc visited =
- let next children acc visited =
- case children of [] -> cont (block : acc) visited
- (b:bs) -> vnode b (next bs) acc visited
- in next bs acc visited
- get_children block = foldl add_id [] (succs block)
- add_id rst id = case lookupBlockEnv blocks id of
- Just b -> b : rst
- Nothing -> rst
-