| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
Game.Goatee.Lib.Tree
Description
SGF data structures modelling the hierarchical game tree.
- data Collection = Collection {
- collectionTrees :: [Node]
- newtype CollectionWithDeepEquality = CollectionWithDeepEquality {}
- data Node = Node {
- nodeProperties :: [Property]
- nodeChildren :: [Node]
- newtype NodeWithDeepEquality = NodeWithDeepEquality {}
- emptyNode :: Node
- rootNode :: Maybe (Int, Int) -> Node
- findProperty :: Descriptor a => a -> Node -> Maybe Property
- findProperty' :: Descriptor a => a -> [Property] -> Maybe Property
- findPropertyValue :: ValuedDescriptor v a => a -> Node -> Maybe v
- findPropertyValue' :: ValuedDescriptor v a => a -> [Property] -> Maybe v
- addProperty :: Property -> Node -> Node
- addChild :: Node -> Node -> Node
- addChildAt :: Int -> Node -> Node -> Node
- deleteChildAt :: Int -> Node -> Node
- validateNode :: Bool -> Bool -> Node -> [String]
Documentation
data Collection Source #
An SGF collection of game trees.
Constructors
| Collection | |
Fields
| |
Instances
newtype CollectionWithDeepEquality Source #
See NodeWithDeepEquality.
Constructors
| CollectionWithDeepEquality | |
Fields | |
An SGF game tree node. Unlike in the SGF spec, we represent a game tree with nodes uniformly, rather than having the separation between sequences and nodes.
Constructors
| Node | |
Fields
| |
newtype NodeWithDeepEquality Source #
A wrapper around Node with an Eq instance that considers two nodes
equal iff they contain the same properties (not necessarily in the same
order), and if they contain children (in the same order) whose nodes are
recursively equal.
This instance is not on Node directly because it is not the only obvious
sense of equality (only comparing properties would be another one), and it's
also potentially expensive.
Constructors
| NodeWithDeepEquality | |
Fields | |
Instances
findProperty :: Descriptor a => a -> Node -> Maybe Property Source #
Searches for a matching property in a node's property list.
findProperty' :: Descriptor a => a -> [Property] -> Maybe Property Source #
Searches for a matching property in a property list.
findPropertyValue :: ValuedDescriptor v a => a -> Node -> Maybe v Source #
Retrieves the value of a property in a node's property list.
findPropertyValue' :: ValuedDescriptor v a => a -> [Property] -> Maybe v Source #
Retrieves the value of a property in a property list.
addChild :: Node -> Node -> Node Source #
addChild child parent appends a child node to a node's child list.
addChildAt :: Int -> Node -> Node -> Node Source #
addChildAt index child parent inserts a child node into a node's child
list at the given index, shifting all nodes at or after the given index to
the right. If the position is less than 0 or greater than the length of the
list, then the index is clamped to this range.