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

Safe HaskellNone

Game.Goatee.Sgf.Property

Contents

Description

Structures and functions for working with SGF node properties.

Synopsis

Properties

data Property Source

An SGF property that gives a node meaning.

Constructors

B (Maybe Coord)

Black move (nothing iff pass).

KO

Execute move unconditionally (even if illegal).

MN Integer

Assign move number.

W (Maybe Coord)

White move (nothing iff pass).

AB CoordList

Assign black stones.

AE CoordList

Assign empty stones.

AW CoordList

Assign white stones.

PL Color

Player to play.

C Text

Comment.

DM DoubleValue

Even position.

GB DoubleValue

Good for black.

GW DoubleValue

Good for white.

HO DoubleValue

Hotspot.

N SimpleText

Node name.

UC DoubleValue

Unclear position.

V RealValue

Node value.

BM DoubleValue

Bad move.

DO

Doubtful move.

IT

Interesting move.

TE DoubleValue

Tesuji.

AR ArrowList

Arrows.

CR CoordList

Mark points with circles.

DD CoordList

Dim points.

LB LabelList

Label points with text.

LN LineList

Lines.

MA CoordList

Mark points with Xs.

SL CoordList

Mark points as selected.

SQ CoordList

Mark points with squares.

TR CoordList

Mark points with trianges.

AP SimpleText SimpleText

Application info.

CA SimpleText

Charset for SimpleText and Text.

FF Int

File format version.

GM Int

Game (must be 1 = Go).

ST VariationMode

Variation display format.

SZ Int Int

Board size, columns then rows.

AN SimpleText

Name of annotator.

BR SimpleText

Rank of black player.

BT SimpleText

Name of black team.

CP SimpleText

Copyright info.

DT SimpleText

Dates played.

EV SimpleText

Event name.

GC SimpleText

Game comment, or background, or summary.

GN SimpleText

Game name.

ON SimpleText

Information about the opening.

OT SimpleText

The method used for overtime.

PB SimpleText

Name of black player.

PC SimpleText

Where the game was played.

PW SimpleText

Name of white player.

RE GameResult

Result of the game.

RO SimpleText

Round info.

RU Ruleset

Ruleset used.

SO SimpleText

Source of the game.

TM RealValue

Time limit, in seconds.

US SimpleText

Name of user or program who entered the game.

WR SimpleText

Rank of white player.

WT SimpleText

Name of white team.

VW CoordList

Set viewing region.

UnknownProperty String UnknownPropertyValue 

Property metadata

data PropertyType Source

The property types that SGF uses to group properties.

Constructors

MoveProperty

Cannot mix with setup nodes.

SetupProperty

Cannot mix with move nodes.

RootProperty

May only appear in root nodes.

GameInfoProperty

At most one on any path.

GeneralProperty

May appear anywhere in the game tree.

class Descriptor a whereSource

A class for types that contain metadata about a Property.

Methods

propertyName :: a -> StringSource

Returns the name of the property, as used in SGF files.

propertyType :: a -> PropertyTypeSource

Returns the type of the property, as specified by the SGF spec.

propertyInherited :: a -> BoolSource

Returns whether the value of the given property is inherited from the lowest ancestor specifying the property, when the property is not set on a node itself.

propertyPredicate :: a -> Property -> BoolSource

Returns whether the given property has the type of a descriptor.

propertyValueParser :: a -> Parser PropertySource

A parser of property values in SGF format (e.g. [ab] for a property that takes a point).

propertyValueRenderer :: a -> Property -> Render ()Source

A renderer property values to SGF format (e.g. B (Just (1,2)) renders to [ab]).

propertyValueRendererPretty :: a -> Property -> Render ()Source

A renderer for displaying property values in a UI. Displays the value in a human-readable format.

data SomeDescriptor Source

Constructors

forall a . Descriptor a => SomeDescriptor a 

class (Descriptor a, Eq v) => ValuedDescriptor a v | a -> v whereSource

A class for Descriptors of Propertys that also contain values.

Methods

propertyValue :: a -> Property -> vSource

Extracts the value from a property of the given type. Behaviour is undefined if the property is not of the given type.

propertyBuilder :: a -> v -> PropertySource

Builds a property from a given value.

Instances

data PropertyInfo Source

Metadata for a property that does not contain a value. Corresponds to a single nullary data constructor of Property.

data ValuedPropertyInfo v Source

Metadata for a property that contains a value. Corresponds to a single unary data constructor of Property.

Property declaration

defPropertySource

Arguments

:: String

The SGF textual name of the property.

-> Name

The name of the PropertyType.

-> Bool

Whether the property is inherited.

-> DecsQ 

Template Haskell function to declare a property that does not contain a value.

 $(defProperty "KO" 'MoveProperty False)

This example declares a propertyKO :: PropertyInfo that is a MoveProperty and is not inherited.

defValuedProperty :: String -> Name -> Bool -> Name -> DecsQSource

Template Haskell function to declare a property that contains a value.

 $(defValuedProperty "B" 'MoveProperty False 'maybeCoordPrinter)

This example declares a propertyB :: ValuedPropertyInfo (Maybe Coord) that is a MoveProperty and is not inherited. The value type is automatically inferred.

markProperty :: Mark -> ValuedPropertyInfo CoordListSource

Returns the descriptor for a mark.