summaryrefslogtreecommitdiffstats
path: root/TreeSearch.hs
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2014-12-25 13:25:54 +0100
committertv <tv@shackspace.de>2014-12-25 13:25:54 +0100
commit9aacdda1f9b94aaa8f0770ebd32b623d8dba3345 (patch)
tree06ed9d5d09af0a338c15aaa7ab2283e64be91dc7 /TreeSearch.hs
parent7ef5bb81b81cd0533719297bbd71c69590d362e6 (diff)
TreeSearch: cleanup
Diffstat (limited to 'TreeSearch.hs')
-rw-r--r--TreeSearch.hs7
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'