From 9aacdda1f9b94aaa8f0770ebd32b623d8dba3345 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 25 Dec 2014 13:25:54 +0100 Subject: TreeSearch: cleanup --- TreeSearch.hs | 7 +++---- 1 file 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' -- cgit v1.2.3