~alcinnz/haskell-stylist

d335eb0efdeefceb52954e94b529296cce0c8028 — Adrian Cochrane 2 years ago c33014e
Expose & fix treeFind/treeFlattenAll utilities.
1 files changed, 4 insertions(+), 4 deletions(-)

M stylist-traits/src/Stylist/Tree.hs
M stylist-traits/src/Stylist/Tree.hs => stylist-traits/src/Stylist/Tree.hs +4 -4
@@ 2,7 2,7 @@
-- Mostly used by callers including (soon) XML Conduit Stylist,
-- but also used internally for generating counter text.
module Stylist.Tree(StyleTree(..), treeOrder, treeOrder',
    Path, treeMap, treeFlatten, preorder, preorder', postorder) where
    Path, treeMap, treeFind, treeFlatten, treeFlattenAll, preorder, preorder', postorder) where

data StyleTree p = StyleTree {
    style :: p,


@@ 36,10 36,10 @@ treeFlatten' (StyleTree _ childs:sibs) = treeFlatten' childs ++ treeFlatten' sib
treeFlatten' [] = []

treeFlattenAll :: StyleTree p -> [p]
treeFlattenAll = treeFlatten' . children
treeFlattenAll = treeFlattenAll' . children
treeFlattenAll' :: [StyleTree p] -> [p]
treeFlattenAll' (StyleTree p []:ps) = p : treeFlatten' ps
treeFlattenAll' (StyleTree p childs:sibs) = p : treeFlatten' childs ++ treeFlatten' sibs
treeFlattenAll' (StyleTree p []:ps) = p : treeFlattenAll' ps
treeFlattenAll' (StyleTree p childs:sibs) = p : treeFlattenAll' childs ++ treeFlattenAll' sibs
treeFlattenAll' [] = []

treeFind :: StyleTree p -> (p -> Bool) -> [p]