diff options
Diffstat (limited to 'TreeSearch.hs')
-rw-r--r-- | TreeSearch.hs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/TreeSearch.hs b/TreeSearch.hs index 51d65c2..7b2e93e 100644 --- a/TreeSearch.hs +++ b/TreeSearch.hs @@ -1,14 +1,13 @@ module TreeSearch where import Data.Tree.Zipper -import Data.Maybe --- findTree :: PosType t => (a -> Bool) -> TreePos t a -> Maybe (TreePos t a) findTree :: (a -> Bool) -> TreePos Full a -> Maybe (TreePos Full a) findTree p loc = if p (label loc) then Just loc else depthFirst loc >>= findTree p - + + depthFirst :: TreePos Full a -> Maybe (TreePos Full a) depthFirst loc = case firstChild loc of Just x -> Just x @@ -20,7 +19,7 @@ depthFirst loc = case firstChild loc of case parent x of Nothing -> Nothing Just x' -> case next x' of - Just x' -> Just x' + Just x'' -> Just x'' Nothing -> parentWithNext x' |