goatee-0.2.0: A monadic take on a 2,500-year-old board game - library.

Safe HaskellNone

Game.Goatee.Lib.Tree

Description

SGF data structures modelling the hierarchical game tree.

Synopsis

Documentation

data Collection Source

An SGF collection of game trees.

Constructors

Collection 

Fields

collectionTrees :: [Node]
 

Instances

data Node Source

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

nodeProperties :: [Property]
 
nodeChildren :: [Node]
 

Instances

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.

emptyNode :: NodeSource

A node with no properties and no children.

rootNode :: Maybe (Int, Int) -> NodeSource

Returns a fresh root Node with AP set to Goatee and optionally with a board size set via SZ.

findProperty :: Descriptor a => a -> Node -> Maybe PropertySource

Searches for a matching property in a node's property list.

findProperty' :: Descriptor a => a -> [Property] -> Maybe PropertySource

Searches for a matching property in a property list.

findPropertyValue :: ValuedDescriptor a v => a -> Node -> Maybe vSource

Retrieves the value of a property in a node's property list.

findPropertyValue' :: ValuedDescriptor a v => a -> [Property] -> Maybe vSource

Retrieves the value of a property in a property list.

addProperty :: Property -> Node -> NodeSource

Appends a property to a node's property list.

addChild :: Node -> Node -> NodeSource

addChild child parent appends a child node to a node's child list.

addChildAt :: Int -> Node -> Node -> NodeSource

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.

deleteChildAt :: Int -> Node -> NodeSource

deleteChildAt index node deletes the child at the given index from the node. If the index is invalid, node is returned.

validateNode :: Bool -> Bool -> Node -> [String]Source

Returns a list of validation errors for the current node, an empty list if no errors are detected.