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

Safe HaskellNone




Structures and functions for working with SGF node properties.



data Property Source

An SGF property that gives a node meaning. A property is known if its meaning is defined by the SGF specification, and unknown otherwise. Known properties each have their own data constructors. Unknown properties are represented by the UnknownProperty data constructor.


B (Maybe Coord)

Black move (nothing iff pass).


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


DM DoubleValue

Even position.

GB DoubleValue

Good for black.

GW DoubleValue

Good for white.

HO DoubleValue


N SimpleText

Node name.

UC DoubleValue

Unclear position.

V RealValue

Node value.

BM DoubleValue

Bad move.


Doubtful move.


Interesting move.

TE DoubleValue


AR ArrowList


CR CoordList

Mark points with circles.

DD CoordList

Dim points.

LB LabelList

Label points with text.

LN LineList


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 Text

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.

BL RealValue

Black time left.

OB Int

Black moves left in byo-yomi period.

OW Int

White moves left in byo-yomi period.

WL RealValue

White time left.

VW CoordList

Set viewing region.

HA Int

Handicap stones (>=2).

KM RealValue


TB CoordList

Black territory.

TW CoordList

White territory.

UnknownProperty String UnknownPropertyValue 

Property metadata

data PropertyType Source

The property types that SGF uses to group properties.



Cannot mix with setup nodes.


Cannot mix with move nodes.


May only appear in root nodes.


At most one on any path.


May appear anywhere in the game tree.

class Descriptor a where Source

A class for types that contain metadata about a Property. The main instance of this class is Property itself; Propertys can be treated as though they have metadata directly. When referring to a property in general rather than a specific instance, use the values of PropertyInfo and ValuedPropertyInfo.

See also ValuedDescriptor.


propertyName :: a -> String Source

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

propertyType :: a -> PropertyType Source

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

propertyInherited :: a -> Bool Source

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 -> Bool Source

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

propertyValueParser :: a -> Parser Property Source

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.

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

A class for Descriptors of properties that also contain values.


propertyValue :: a -> Property -> v Source

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 -> Property Source

Builds a property from a given value.

data AnyDescriptor Source

An existential type for any property descriptor. AnyDescriptor has a Descriptor instance, so there is no need to extract the value with a pattern match before using Descriptor methods.


forall a . Descriptor a => AnyDescriptor a 

data AnyValuedDescriptor v Source

An existential type for any descriptor of a property that holds a value of a specific type. Has instances for Descriptor and ValuedDescriptor, similar to AnyDescriptor.


forall a . ValuedDescriptor v a => AnyValuedDescriptor a 

data PropertyInfo Source

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

data ValuedPropertyInfo v Source

Metadata for a property that contains a value. Corresponds to a non-nullary data constructor of Property.


ValuedPropertyInfo String PropertyType Bool (Property -> Bool) (PropertyValueType v) (Property -> v) (v -> Property) 

(Internal) Property metadata declaration

defProperty Source


:: String

The SGF textual name of the property.

-> Name

The name of the PropertyType.

-> Bool

Whether the property is inherited.

-> DecsQ 

Internal to this module, do not use outside. 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 -> DecsQ Source

Internal to this module, do not use outside. 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.

Known property metadata

Property metadata utilities

allKnownDescriptors :: [AnyDescriptor] Source

A list of descriptors for all known Propertys.

propertyUnknown :: String -> ValuedPropertyInfo UnknownPropertyValue Source

Builds a ValuedPropertyInfo for an unknown property with the given name. Does not check that the name is actually unknown.

propertyInfo :: Property -> AnyDescriptor Source

Returns a descriptor for any Property, known or unknown. Because a Property has a Descriptor instance, this function is not normally necessary for use outside of this module, but it can be used to throw away a value associated with a Property and retain only the metadata.

descriptorForName :: String -> AnyDescriptor Source

Returns a descriptor for the given property name. The name does not have to be for a known property; an unknown property will use propertyUnknown.

descriptorForName' :: String -> Maybe AnyDescriptor Source

Returns a descriptor for a known property with the given name, or Nothing if the name does not belong to a known property.

stoneAssignmentProperties :: [AnyCoordListDescriptor] Source

Descriptors for setup properties that assign stones to the board. For use with stoneAssignmentPropertyToStone and stoneToStoneAssignmentProperty.

stoneAssignmentPropertyToStone :: AnyCoordListDescriptor -> Maybe Color Source

Converts a descriptor in stoneAssignmentProperties to the type of stone it assigns.

stoneToStoneAssignmentProperty :: Maybe Color -> AnyCoordListDescriptor Source

Converts a type of stone assignment to a descriptor in stoneAssignmentProperties.

markProperty :: Mark -> ValuedPropertyInfo CoordList Source

Returns the descriptor for a mark.