Safe Haskell | None |
---|
Structures and functions for working with SGF node properties.
- data Property
- = B (Maybe Coord)
- | KO
- | MN Integer
- | W (Maybe Coord)
- | AB CoordList
- | AE CoordList
- | AW CoordList
- | PL Color
- | C Text
- | DM DoubleValue
- | GB DoubleValue
- | GW DoubleValue
- | HO DoubleValue
- | N SimpleText
- | UC DoubleValue
- | V RealValue
- | BM DoubleValue
- | DO
- | IT
- | TE DoubleValue
- | AR ArrowList
- | CR CoordList
- | DD CoordList
- | LB LabelList
- | LN LineList
- | MA CoordList
- | SL CoordList
- | SQ CoordList
- | TR CoordList
- | AP SimpleText SimpleText
- | CA SimpleText
- | FF Int
- | GM Int
- | ST VariationMode
- | SZ Int Int
- | AN SimpleText
- | BR SimpleText
- | BT SimpleText
- | CP SimpleText
- | DT SimpleText
- | EV SimpleText
- | GC SimpleText
- | GN SimpleText
- | ON SimpleText
- | OT SimpleText
- | PB SimpleText
- | PC SimpleText
- | PW SimpleText
- | RE GameResult
- | RO SimpleText
- | RU Ruleset
- | SO SimpleText
- | TM RealValue
- | US SimpleText
- | WR SimpleText
- | WT SimpleText
- | VW CoordList
- | UnknownProperty String UnknownPropertyValue
- data PropertyType
- class Descriptor a where
- propertyName :: a -> String
- propertyType :: a -> PropertyType
- propertyInherited :: a -> Bool
- propertyPredicate :: a -> Property -> Bool
- propertyValueParser :: a -> Parser Property
- propertyValueRenderer :: a -> Property -> Render ()
- propertyValueRendererPretty :: a -> Property -> Render ()
- data SomeDescriptor = forall a . Descriptor a => SomeDescriptor a
- class (Descriptor a, Eq v) => ValuedDescriptor a v | a -> v where
- propertyValue :: a -> Property -> v
- propertyBuilder :: a -> v -> Property
- data PropertyInfo
- data ValuedPropertyInfo v = ValuedPropertyInfo String PropertyType Bool (Property -> Bool) (PropertyValueType v) (Property -> v) (v -> Property)
- defProperty :: String -> Name -> Bool -> DecsQ
- defValuedProperty :: String -> Name -> Bool -> Name -> DecsQ
- propertyB :: ValuedPropertyInfo (Maybe Coord)
- propertyKO :: PropertyInfo
- propertyMN :: ValuedPropertyInfo Integer
- propertyW :: ValuedPropertyInfo (Maybe Coord)
- propertyAB :: ValuedPropertyInfo CoordList
- propertyAE :: ValuedPropertyInfo CoordList
- propertyAW :: ValuedPropertyInfo CoordList
- propertyPL :: ValuedPropertyInfo Color
- propertyC :: ValuedPropertyInfo Text
- propertyDM :: ValuedPropertyInfo DoubleValue
- propertyGB :: ValuedPropertyInfo DoubleValue
- propertyGW :: ValuedPropertyInfo DoubleValue
- propertyHO :: ValuedPropertyInfo DoubleValue
- propertyN :: ValuedPropertyInfo SimpleText
- propertyUC :: ValuedPropertyInfo DoubleValue
- propertyV :: ValuedPropertyInfo RealValue
- propertyBM :: ValuedPropertyInfo DoubleValue
- propertyDO :: PropertyInfo
- propertyIT :: PropertyInfo
- propertyTE :: ValuedPropertyInfo DoubleValue
- propertyAR :: ValuedPropertyInfo ArrowList
- propertyCR :: ValuedPropertyInfo CoordList
- propertyDD :: ValuedPropertyInfo CoordList
- propertyLB :: ValuedPropertyInfo LabelList
- propertyLN :: ValuedPropertyInfo LineList
- propertyMA :: ValuedPropertyInfo CoordList
- propertySL :: ValuedPropertyInfo CoordList
- propertySQ :: ValuedPropertyInfo CoordList
- propertyTR :: ValuedPropertyInfo CoordList
- propertyAP :: ValuedPropertyInfo (SimpleText, SimpleText)
- propertyCA :: ValuedPropertyInfo SimpleText
- propertyFF :: ValuedPropertyInfo Int
- propertyGM :: ValuedPropertyInfo Int
- propertyST :: ValuedPropertyInfo VariationMode
- propertySZ :: ValuedPropertyInfo (Int, Int)
- propertyAN :: ValuedPropertyInfo SimpleText
- propertyBR :: ValuedPropertyInfo SimpleText
- propertyBT :: ValuedPropertyInfo SimpleText
- propertyCP :: ValuedPropertyInfo SimpleText
- propertyDT :: ValuedPropertyInfo SimpleText
- propertyEV :: ValuedPropertyInfo SimpleText
- propertyGC :: ValuedPropertyInfo SimpleText
- propertyGN :: ValuedPropertyInfo SimpleText
- propertyON :: ValuedPropertyInfo SimpleText
- propertyOT :: ValuedPropertyInfo SimpleText
- propertyPB :: ValuedPropertyInfo SimpleText
- propertyPC :: ValuedPropertyInfo SimpleText
- propertyPW :: ValuedPropertyInfo SimpleText
- propertyRE :: ValuedPropertyInfo GameResult
- propertyRO :: ValuedPropertyInfo SimpleText
- propertyRU :: ValuedPropertyInfo Ruleset
- propertySO :: ValuedPropertyInfo SimpleText
- propertyTM :: ValuedPropertyInfo RealValue
- propertyUS :: ValuedPropertyInfo SimpleText
- propertyWR :: ValuedPropertyInfo SimpleText
- propertyWT :: ValuedPropertyInfo SimpleText
- propertyVW :: ValuedPropertyInfo CoordList
- propertyUnknown :: String -> ValuedPropertyInfo UnknownPropertyValue
- allDescriptors :: [SomeDescriptor]
- propertyInfo :: Property -> SomeDescriptor
- descriptorsByName :: Map String SomeDescriptor
- descriptorForName :: String -> SomeDescriptor
- descriptorForName' :: String -> Maybe SomeDescriptor
- markProperty :: Mark -> ValuedPropertyInfo CoordList
- data PropertyValueType a
- pvtParser :: PropertyValueType a -> Parser a
- pvtRenderer :: PropertyValueType a -> a -> Render ()
- pvtRendererPretty :: PropertyValueType a -> a -> Render ()
Properties
An SGF property that gives a node meaning.
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 |
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.
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
.
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.
class (Descriptor a, Eq v) => ValuedDescriptor a v | a -> v whereSource
A class for Descriptor
s of Property
s that also contain values.
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.
Eq v => ValuedDescriptor (ValuedPropertyInfo v) v |
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
.
ValuedPropertyInfo String PropertyType Bool (Property -> Bool) (PropertyValueType v) (Property -> v) (v -> Property) |
Descriptor (ValuedPropertyInfo v) | |
Eq v => ValuedDescriptor (ValuedPropertyInfo v) v |
Property declaration
:: String | The SGF textual name of the property. |
-> Name | The name of the |
-> 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 ::
that is a
PropertyInfo
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 ::
that is a ValuedPropertyInfo
(Maybe Coord
)MoveProperty
and is not inherited. The value type is
automatically inferred.
markProperty :: Mark -> ValuedPropertyInfo CoordListSource
Returns the descriptor for a mark.
data PropertyValueType a Source
pvtParser :: PropertyValueType a -> Parser aSource
pvtRenderer :: PropertyValueType a -> a -> Render ()Source
pvtRendererPretty :: PropertyValueType a -> a -> Render ()Source