diff options
author | Marvin Borner | 2022-03-03 15:56:53 +0100 |
---|---|---|
committer | Marvin Borner | 2022-03-03 15:56:53 +0100 |
commit | 4d5aa27a4636abcf58afeec83e598118eb02fb5c (patch) | |
tree | ead37ffe2b89e2f692a71672c4ec1fab00487b06 /src/Fun/Tree.hs | |
parent | 65293eedaf3469bb0f4a0b174cd53bb89c762ff5 (diff) |
Tree
Diffstat (limited to 'src/Fun/Tree.hs')
-rw-r--r-- | src/Fun/Tree.hs | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/Fun/Tree.hs b/src/Fun/Tree.hs index 5de4695..354677d 100644 --- a/src/Fun/Tree.hs +++ b/src/Fun/Tree.hs @@ -36,36 +36,3 @@ data FunctionBody = FunctionBody [FunctionBodyElement] deriving Show data FunctionBodyElement = Statement String | FunctionBodyIdentifier String | FunctionBodyParameter String | FunctionBodyString String | FunctionBodyNumber Integer deriving Show - ----- - -data NodeValue = NodeName String | FunctionBlockNode FunctionBlock -- | Type, Lambda, .. (TODO) - deriving Show -data EmptyValue = EmptyValue - deriving Show -data Node = EmptyNode | Node NodeValue [Node] - deriving Show -data Crumb = Crumb NodeValue [Node] [Node] - deriving Show -type Zipper = (Node, [Crumb]) - -(-:) :: Maybe Zipper -> (Maybe Zipper -> Maybe Zipper) -> Maybe Zipper -u -: f = f u - -nodePred :: (NodeValue -> Bool) -> Node -> Bool -nodePred pred (Node value _) = pred value -nodePred _ _ = False - --- One layer search from top -treeTo :: (NodeValue -> Bool) -> Maybe Zipper -> Maybe Zipper -treeTo _ Nothing = Nothing -treeTo pred (Just (EmptyNode, _)) = Nothing -treeTo pred (Just (Node value nodes, bs)) = - let (ls, node : rs) = break (nodePred pred) nodes - in Just (node, Crumb value ls rs : bs) - -treeUp :: Maybe Zipper -> Maybe Zipper -treeUp Nothing = Nothing -treeUp (Just (EmptyNode, _)) = Nothing -treeUp (Just (node, Crumb value ls rs : bs)) = - Just (Node value (ls ++ [node] ++ rs), bs) |