data-named-0.6.2: Data types for named entities

Safe HaskellSafe
LanguageHaskell2010

Data.Named.Tree

Contents

Description

Working with NE trees and forests.

Synopsis

Auxiliary types

type NeTree a b = Tree (Either a b) Source #

A tree with a values in internal nodes and b values in leaves.

type NeForest a b = Forest (Either a b) Source #

A forest with a values in internal nodes and b values in leaves.

Span

data Span w Source #

Spanning of a tree.

Constructors

Span 

Fields

Instances
Eq w => Eq (Span w) Source # 
Instance details

Defined in Data.Named.Tree

Methods

(==) :: Span w -> Span w -> Bool #

(/=) :: Span w -> Span w -> Bool #

Ord w => Ord (Span w) Source # 
Instance details

Defined in Data.Named.Tree

Methods

compare :: Span w -> Span w -> Ordering #

(<) :: Span w -> Span w -> Bool #

(<=) :: Span w -> Span w -> Bool #

(>) :: Span w -> Span w -> Bool #

(>=) :: Span w -> Span w -> Bool #

max :: Span w -> Span w -> Span w #

min :: Span w -> Span w -> Span w #

Show w => Show (Span w) Source # 
Instance details

Defined in Data.Named.Tree

Methods

showsPrec :: Int -> Span w -> ShowS #

show :: Span w -> String #

showList :: [Span w] -> ShowS #

leafSpan :: w -> Span w Source #

Make span for a leaf node.

(<>) :: Ord w => Span w -> Span w -> Span w Source #

Minimum span overlapping both input spans.

spanSet :: Ix w => Span w -> Set w Source #

Set of positions covered by the span.

Trees with span

span :: Tree (a, Span w) -> Span w Source #

Get span of the span-annotated tree.

spanTree :: Ord w => Tree (Either n w) -> Tree (Either n w, Span w) Source #

Annotate tree nodes with spanning info given the function which assignes indices to leaf nodes.

spanForest :: Ord w => Forest (Either n w) -> Forest (Either n w, Span w) Source #

Annotate forest nodes with spanning info.

unSpanTree :: Tree (k, Span w) -> Tree k Source #

Remove span annotations from the tree.

unSpanForest :: Forest (k, Span w) -> Forest k Source #

Remove span annotations from the forest.

sortTree :: Ord w => Tree (k, Span w) -> Tree (k, Span w) Source #

Sort the tree with respect to spanning info.

sortForest :: Ord w => Forest (k, Span w) -> Forest (k, Span w) Source #

Sort the forest with respect to spanning info.

Utilities

mapForest :: (a -> b) -> Forest a -> Forest b Source #

Map function over each tree from the forest.

mapTree :: (a -> b) -> Tree a -> Tree b Source #

Map function over the tree.

onLeaf :: (a -> b) -> Either c a -> Either c b Source #

Map function over the leaf value.

onNode :: (a -> b) -> Either a c -> Either b c Source #

Map function over the internal node value.

onEither :: (a -> c) -> (b -> d) -> Either a b -> Either c d Source #

Map the first function over internal node value and the second one over leaf value.

onBoth :: (a -> b) -> Either a a -> Either b b Source #

Map one function over both node and leaf values.

groupForestLeaves :: (b -> b -> Bool) -> NeForest a b -> NeForest a [b] Source #

Group leaves with respect to the given equality function.

groupTreeLeaves :: (b -> b -> Bool) -> NeTree a b -> NeTree a [b] Source #

Group leaves with respect to the given equality function.

concatForestLeaves :: NeForest a [b] -> NeForest a b Source #

Group leaves with respect to the given equality function.

concatTreeLeaves :: NeTree a [b] -> NeForest a b Source #

Group leaves with respect to the given equality function.

module Data.Tree