yi- The Haskell-Scriptable Editor



Generic syntax tree handling functions



class Foldable tree => IsTree tree whereSource


subtrees :: tree t -> [tree t]Source

Direct subtrees of a tree

uniplate :: tree t -> ([tree t], [tree t] -> tree t)Source

emptyNode :: tree tSource

toksAfter :: Foldable t1 => t -> t1 a -> [a]Source

allToks :: Foldable t => t a -> [a]Source

tokAtOrBefore :: Foldable t => Point -> t (Tok t1) -> Maybe (Tok t1)Source

toksInRegion :: Foldable t1 => Region -> t1 (Tok t) -> [Tok t]Source

sepBy :: Alternative f => f a -> f v -> f [a]Source

sepBy1 :: Alternative f => f a -> f v -> f [a]Source

getFirstElement :: Foldable t => t a -> Maybe aSource

Return the 1st token of a subtree.

getLastElement :: Foldable t => t a -> Maybe aSource

Return the last token of a subtree.

getLastPath :: IsTree tree => [tree (Tok t)] -> Point -> Maybe [tree (Tok t)]Source

Search the given list, and return the last tree before the given point; with path to the root. (Root is at the start of the path)

getAllSubTrees :: IsTree tree => tree t -> [tree t]Source

Return all subtrees in a tree, in preorder.

tokenBasedAnnots :: Foldable t1 => (a1 -> Maybe a) -> t1 a1 -> t -> [a]Source

tokenBasedStrokes :: Foldable t3 => (a -> b) -> t3 a -> t -> t2 -> t1 -> [b]Source

fromLeafToLeafAfter :: IsTree tree => Point -> Node (tree (Tok a)) -> Node (tree (Tok a))Source

Search the tree in pre-order starting at a given node, until finding a leaf which is at or after the given point. An effort is also made to return a leaf as close as possible to p. TODO: rename to fromLeafToLeafAt

fromNodeToFinal :: IsTree tree => Region -> Node (tree (Tok a)) -> Node (tree (Tok a))Source

Given an approximate path to a leaf at the end of the region, return: (path to leaf at the end of the region,path from focused node to the leaf, small node encompassing the region)