-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | SGF (Smart Game Format) parser
--
-- This is a parser for the go/igo/weiqi/baduk fragment of the SGF
-- format. Encodings latin-1, utf-8, and ascii are supported, and the
-- parser strives to be robust to minor errors, especially those made by
-- the most common SGF editors. There are plans to support other games
-- and pretty-printing in future releases.
@package sgf
@version 0.1
-- | Types used to represent an SGF tree. Whenever a data type is used by
-- exactly one other data type, there will be a "see also" link to its
-- containing type.
module Data.SGF.Types
-- | See also Collection.
data Game
Game :: Maybe (Application, Version) -> Maybe (VariationType, AutoMarkup) -> Maybe (Integer, Integer) -> GameTree -> Game
-- | The name and version number of the application used to create this
-- game. The version number must be in a format that allows ordinary
-- string comparison to tell which version is higher or lower. Neither
-- the application name nor the version number may have newlines. See
-- also http://www.red-bean.com/sgf/properties.html#AP
application :: Game -> Maybe (Application, Version)
-- | The first argument tells whether children (False) or siblings (True)
-- are variations; the second argument tells whether or not to show board
-- markup when variations are available. See also
-- http://www.red-bean.com/sgf/properties.html#ST
variationType :: Game -> Maybe (VariationType, AutoMarkup)
-- | The size of the board. For games with a default board size, this is
-- guaranteed to be a Just. See also
-- http://www.red-bean.com/sgf/properties.html#SZ
size :: Game -> Maybe (Integer, Integer)
-- | The actual game tree.
tree :: Game -> GameTree
-- | See also Game.
data GameTree
TreeGo :: TreeGo -> GameTree
TreeBackgammon :: TreeBackgammon -> GameTree
TreeLinesOfAction :: TreeLinesOfAction -> GameTree
-- | Applications can store and read settings in the first argument here.
-- This got totally shoehorned into the spec by some particular viewer,
-- I'm sure, but it's in the spec now, so there we go. See also
-- http://www.red-bean.com/sgf/hex.html#IS
TreeHex :: [(ViewerSetting, Bool)] -> TreeHex -> GameTree
TreeOcti :: TreeOcti -> GameTree
TreeOther :: GameType -> TreeOther -> GameTree
-- | See also GameTree.
data GameNode move stone ruleSet extraGameInfo extraAnnotation
GameNode :: Maybe (GameInfo ruleSet extraGameInfo) -> Either (Setup stone) (Move move) -> Annotation extraAnnotation -> Markup -> Map String [[Word8]] -> GameNode move stone ruleSet extraGameInfo extraAnnotation
-- | All properties with propertytype game-info. There must be only one
-- Just on any path within a GameTree.
gameInfo :: GameNode move stone ruleSet extraGameInfo extraAnnotation -> Maybe (GameInfo ruleSet extraGameInfo)
-- | All properties with propertytype setup or move.
action :: GameNode move stone ruleSet extraGameInfo extraAnnotation -> Either (Setup stone) (Move move)
-- | Positional judgments and comments (as opposed to judgments of
-- particular moves). All properties covered in the "Node annotation"
-- section.
annotation :: GameNode move stone ruleSet extraGameInfo extraAnnotation -> Annotation extraAnnotation
-- | How a node should be displayed. All properties covered in the "Markup"
-- and "Miscellaneous" sections.
markup :: GameNode move stone ruleSet extraGameInfo extraAnnotation -> Markup
-- | Unspecified properties. The keys in the map must contain only the
-- characters A-Z (and must be upper-case). The values in the map may be
-- more or less arbitrary, but any occurrence of the ASCII byte ']' must
-- be preceded by an odd number of copies of the ASCII byte '\'. See also
-- http://www.red-bean.com/sgf/sgf4.html#2.2
unknown :: GameNode move stone ruleSet extraGameInfo extraAnnotation -> Map String [[Word8]]
-- | See also GameNode.
data Move move
Move :: Maybe (Color, move) -> FuzzyBool -> Maybe Integer -> Maybe Quality -> Maybe Rational -> Maybe Rational -> Maybe Integer -> Maybe Integer -> Move move
-- | The given move should be executed, whether it is illegal or not. See
-- also the B and W properties at
-- http://www.red-bean.com/sgf/properties.html#B
move :: Move move -> Maybe (Color, move)
-- | When set to Definitely, the current move is acknowledged to be
-- illegal. When set to Possibly, the move may be legal or
-- illegal. See also
-- http://www.red-bean.com/sgf/properties.html#KO
illegal :: Move move -> FuzzyBool
-- | When Just, set the current move number. See also
-- http://www.red-bean.com/sgf/properties.html#MN
number :: Move move -> Maybe Integer
-- | An annotation telling the quality of the current move. This annotation
-- makes no bigger-picture positional judgments; for those, see
-- Annotation. See also the BM, DO, IT, and TE properties at
-- http://www.red-bean.com/sgf/properties.html#BM
quality :: Move move -> Maybe Quality
-- | Time remaining, in seconds, for the black player after this move was
-- made. See also http://www.red-bean.com/sgf/properties.html#BL
timeBlack :: Move move -> Maybe Rational
-- | Time remaining, in seconds, for the white player after this move was
-- made. See also http://www.red-bean.com/sgf/properties.html#WL
timeWhite :: Move move -> Maybe Rational
-- | Number of overtime moves left for the black player after this move was
-- made. See also http://www.red-bean.com/sgf/properties.html#OB
overtimeMovesBlack :: Move move -> Maybe Integer
-- | Number of overtime moves left for the white player after this move was
-- made. See also http://www.red-bean.com/sgf/properties.html#OW
overtimeMovesWhite :: Move move -> Maybe Integer
-- | See also GameNode. Setup nodes are distinct from
-- Move nodes in that they need not correspond to any natural part
-- of the game, and game rules (e.g. for capture) are not applied after
-- executing Setup nodes. They can be used for any non-standard
-- changes to the game board or to create illegal board positions. The
-- locations specified in the addBlack, addWhite, and
-- remove fields must be pairwise disjoint.
data Setup stone
Setup :: Set stone -> Set stone -> Set Point -> Maybe Color -> Setup stone
-- | This node adds the given black pieces to the board; if the board
-- before this setup node had any pieces at the locations given by this
-- field, they are overridden. See also
-- http://www.red-bean.com/sgf/properties.html#AB
addBlack :: Setup stone -> Set stone
-- | This node adds the given white pieces to the board; if the board
-- before this setup node had any pieces at the locations given by this
-- field, they are overridden. See also
-- http://www.red-bean.com/sgf/properties.html#AW
addWhite :: Setup stone -> Set stone
-- | This node specifies locations of the board to clear. See also
-- http://www.red-bean.com/sgf/properties.html#AE
remove :: Setup stone -> Set Point
-- | Specify which player should move next. See also
-- http://www.red-bean.com/sgf/properties.html#PL
toPlay :: Setup stone -> Maybe Color
-- | See also GameNode.
data Annotation extra
Annotation :: Maybe String -> Maybe String -> Maybe Emphasis -> Maybe Rational -> Maybe (Judgment, Emphasis) -> extra -> Annotation extra
-- | Free-form text describing the current node. See also
-- http://www.red-bean.com/sgf/properties.html#C
comment :: Annotation extra -> Maybe String
-- | A very short description of the node. Must not contain newlines. See
-- also http://www.red-bean.com/sgf/properties.html#N
name :: Annotation extra -> Maybe String
-- | When Just, this node contains something interesting. Viewers
-- should show a message. See also
-- http://www.red-bean.com/sgf/properties.html#HO
hotspot :: Annotation extra -> Maybe Emphasis
-- | A quantitative full-board positional judgment. Positive values are
-- good for black, negative for white. See also
-- http://www.red-bean.com/sgf/properties.html#V
value :: Annotation extra -> Maybe Rational
-- | A qualitative full-board positional judgment. See also the GB, GW, DM,
-- and UC properties at
-- http://www.red-bean.com/sgf/properties.html#DM
judgment :: Annotation extra -> Maybe (Judgment, Emphasis)
-- | Game-specific annotations.
otherAnnotation :: Annotation extra -> extra
-- | See also GameNode. Presumably, no arrow in the arrows
-- field should exactly overlap a line specified in the lines
-- field; however, this is not explicitly made illegal by the SGF spec.
-- Note that some fields are marked "inherit". These inheritances are not
-- explicitly tracked; Nothing values indicate that the correct
-- interpretation depends on the node's ancestors, or on the default if
-- no ancestor has a Just value in this field.
data Markup
Markup :: Map Point Mark -> Map Point String -> Set (Point, Point) -> Set (Point, Point) -> Maybe (Set Point) -> Maybe (Set Point) -> Maybe Numbering -> Maybe Figure -> Markup
-- | See also the CR, MA, SL, SQ, and TR properties at
-- http://www.red-bean.com/sgf/properties.html#CR
marks :: Markup -> Map Point Mark
-- | Typically, the Strings will be single letters, but that is
-- not guaranteed. Labels must not contain newlines. See also
-- http://www.red-bean.com/sgf/properties.html#LB
labels :: Markup -> Map Point String
-- | Arrows must not start and end at the same point. See also
-- http://www.red-bean.com/sgf/properties.html#AR
arrows :: Markup -> Set (Point, Point)
-- | Lines must not start and end at the same point. Lines must not be
-- repeated; the parser guarantees this by only including pairs (p,
-- q) in which p < q. See also
-- http://www.red-bean.com/sgf/properties.html#LN
lines :: Markup -> Set (Point, Point)
-- | Shade out (exactly) the given points. This property is inherited,
-- defaulting to Set.empty. See also
-- http://www.red-bean.com/sgf/properties.html#DD
dim :: Markup -> Maybe (Set Point)
-- | Make (exactly) the given points visible; do not draw any of the other
-- points. This property is inherited, defaulting to the entire board,
-- and Set.empty resets to the default. See also
-- http://www.red-bean.com/sgf/properties.html#VW
visible :: Markup -> Maybe (Set Point)
-- | How move numbers should be printed on the board. This property is
-- inherited, defaulting to Numbered. See also
-- http://www.red-bean.com/sgf/properties.html#PM
numbering :: Markup -> Maybe Numbering
-- | When Just, a new diagram should begin at this move. See also
-- http://www.red-bean.com/sgf/properties.html#FG
figure :: Markup -> Maybe Figure
-- | See also GameNode. Each individual game may have at most one
-- node with associated game info. If it has such a node, it must occur
-- at the first node where that game is distinguishable from all of the
-- other games in the tree.
data GameInfo ruleSet extra
GameInfo :: Maybe Rank -> Maybe Rank -> Set PartialDate -> Maybe Round -> Maybe (RuleSet ruleSet) -> Maybe Rational -> Maybe GameResult -> Map GameInfoType String -> extra -> GameInfo ruleSet extra
-- | The strength of the black player. See also
-- http://www.red-bean.com/sgf/properties.html#BR
rankBlack :: GameInfo ruleSet extra -> Maybe Rank
-- | The strength of the white player. See also
-- http://www.red-bean.com/sgf/properties.html#WR
rankWhite :: GameInfo ruleSet extra -> Maybe Rank
-- | When the game was played. An empty set indicates that no date
-- information is available. See also
-- http://www.red-bean.com/sgf/properties.html#DT
date :: GameInfo ruleSet extra -> Set PartialDate
-- | The round number (for games played in a tournament). See also
-- http://www.red-bean.com/sgf/properties.html#RO
round :: GameInfo ruleSet extra -> Maybe Round
-- | The ruleset used for this game. See also
-- http://www.red-bean.com/sgf/properties.html#RU
ruleSet :: GameInfo ruleSet extra -> Maybe (RuleSet ruleSet)
-- | The time limit of the game in seconds. See also
-- http://www.red-bean.com/sgf/properties.html#TM
timeLimit :: GameInfo ruleSet extra -> Maybe Rational
-- | How the game ended. See also
-- http://www.red-bean.com/sgf/properties.html#RE
result :: GameInfo ruleSet extra -> Maybe GameResult
-- | Miscellaneous properties with no prescribed format.
freeform :: GameInfo ruleSet extra -> Map GameInfoType String
-- | Certain game types specify additional informational properties, which
-- are stored here.
otherGameInfo :: GameInfo ruleSet extra -> extra
-- | See also GameInfo, especially the freeform field.
data GameInfoType
-- | See also the BT and WT properties at
-- http://www.red-bean.com/sgf/properties.html#BT
TeamName :: Color -> GameInfoType
-- | See also the PB and PW properties at
-- http://www.red-bean.com/sgf/properties.html#PB
PlayerName :: Color -> GameInfoType
-- | The name of the person who annotated the game. See also
-- http://www.red-bean.com/sgf/properties.html#AN
Annotator :: GameInfoType
-- | The name of the source, e.g. the title of the book this game came
-- from. See also http://www.red-bean.com/sgf/properties.html#SO
Source :: GameInfoType
-- | The name of the person or program who entered the game. See also
-- http://www.red-bean.com/sgf/properties.html#US
User :: GameInfoType
-- | See also http://www.red-bean.com/sgf/properties.html#CP
Copyright :: GameInfoType
-- | Background information or a summary of the game. See also
-- http://www.red-bean.com/sgf/properties.html#GC
Context :: GameInfoType
-- | Where the game was played. See also
-- http://www.red-bean.com/sgf/properties.html#PC
Location :: GameInfoType
-- | The name of the event or tournament at which the game occurred.
-- Additional information about the game (e.g. that it was in the finals)
-- should appear in the round field, not here. See also
-- http://www.red-bean.com/sgf/properties.html#EV
Event :: GameInfoType
-- | An easily-remembered moniker for the game. See also
-- http://www.red-bean.com/sgf/properties.html#GN
GameName :: GameInfoType
-- | A description of the opening moves using the game's vernacular. See
-- also http://www.red-bean.com/sgf/properties.html#ON
Opening :: GameInfoType
-- | The overtime rules. See also
-- http://www.red-bean.com/sgf/properties.html#OT
Overtime :: GameInfoType
emptyGameNode :: GameNode move stone ruleSet extraGameInfo ()
emptyMove :: Move move
emptySetup :: Setup stone
emptyGameInfo :: GameInfo ruleSet ()
emptyAnnotation :: Annotation ()
emptyMarkup :: Markup
-- | See also TreeGo and Game.
type NodeGo = GameNode MoveGo Point RuleSetGo GameInfoGo AnnotationGo
-- | See also NodeGo and Game.
data MoveGo
Pass :: MoveGo
Play :: Point -> MoveGo
-- | See also RuleSet, GameInfo, and
-- http://red-bean.com/sgf/properties.html#RU
data RuleSetGo
-- | American Go Association rules
AGA :: RuleSetGo
-- | Ing rules
GOE :: RuleSetGo
Chinese :: RuleSetGo
Japanese :: RuleSetGo
NewZealand :: RuleSetGo
-- | See also NodeGo and the otherGameInfo field of
-- GameInfo.
data GameInfoGo
GameInfoGo :: Maybe Integer -> Maybe Rational -> GameInfoGo
-- | Specifying this does not automatically add stones to the board; a
-- Setup node with a non-empty addBlack field should be
-- specified before any Move nodes. See also
-- http://red-bean.com/sgf/go.html#HA
handicap :: GameInfoGo -> Maybe Integer
-- | See also http://red-bean.com/sgf/go.html#KM
komi :: GameInfoGo -> Maybe Rational
-- | See also NodeGo and the otherAnnotation field of
-- Annotation. This specifies which points are considered
-- territory for each player. See also the TB and TW properties at
-- http://red-bean.com/sgf/go.html#TB
type AnnotationGo = Map Color (Set Point)
-- | See also TreeBackgammon and Game.
type NodeBackgammon = GameNode () () RuleSetBackgammon GameInfoBackgammon ()
-- | See also RuleSet, GameInfo, and
-- http://red-bean.com/sgf/backgammon.html#RU
data RuleSetBackgammon
-- | The Crawford rule is being used.
Crawford :: RuleSetBackgammon
-- | This game is the Crawford game.
CrawfordGame :: RuleSetBackgammon
-- | The Jacoby rule is being used.
Jacoby :: RuleSetBackgammon
-- | See also NodeBackgammon and the otherGameInfo field of
-- GameInfo. An empty list indicates that no match information was
-- specified. The order of the list is not significant, and there should
-- be only one value of any given kind of MatchInfo. See also
-- http://red-bean.com/sgf/backgammon.html#MI
type GameInfoBackgammon = [MatchInfo]
-- | See also GameInfoBackgammon and
-- http://red-bean.com/sgf/backgammon.html#MI
data MatchInfo
-- | The number of points in this match.
Length :: Integer -> MatchInfo
-- | The (1-indexed) number of the game within this match.
GameNumber :: Integer -> MatchInfo
-- | The score at the beginning of the game.
StartScore :: Color -> Integer -> MatchInfo
-- | An unknown piece of match information.
OtherMatchInfo :: String -> String -> MatchInfo
-- | See also TreeLinesOfAction and Game.
type NodeLinesOfAction = GameNode () () Void GameInfoLinesOfAction ()
-- | See also NodeLinesOfAction and the otherGameInfo field
-- of GameInfo.
data GameInfoLinesOfAction
GameInfoLinesOfAction :: InitialPosition -> Bool -> InitialPlacement -> GameInfoLinesOfAction
-- | When this field is Beginning, the viewer should initially show
-- the board position after setup but before any moves. (When End,
-- the viewer should display the final position.) See also
-- http://www.red-bean.com/sgf/loa.html#IP
initialPositionLOA :: GameInfoLinesOfAction -> InitialPosition
-- | When this field is True, the board should be displayed with
-- numbers increasing from the bottom to the top of the screen. (When
-- False, the numbers should be decreasing.) See also
-- http://www.red-bean.com/sgf/loa.html#IY
invertYAxis :: GameInfoLinesOfAction -> Bool
-- | The initial placement of pieces and rule variation. See also
-- http://www.red-bean.com/sgf/loa.html#SU
initialPlacement :: GameInfoLinesOfAction -> InitialPlacement
-- | See also GameInfoLinesOfAction.
data InitialPosition
Beginning :: InitialPosition
End :: InitialPosition
-- | See also GameInfoLinesOfAction.
data InitialPlacement
Standard :: InitialPlacement
ScrambledEggs :: InitialPlacement
Parachute :: InitialPlacement
Gemma :: InitialPlacement
Custom :: InitialPlacement
-- | See also TreeHex and Game.
type NodeHex = GameNode () () Void GameInfoHex ()
-- | See also NodeHex and the otherGameInfo field of
-- GameInfo. The specification says that trees representing Hex
-- games will mark which position the viewer should initially show by
-- setting this field to True. I think this is probably an error
-- in the specification; there is an obvious conflict between the
-- requirement to put all game information at the first node where a game
-- is uniquely identifiable and the requirement to have a
-- game-information property at the location you want to view first
-- (whenever these two nodes are not the same node, of course). For this
-- reason, Hex game trees may have paths containing two nodes whose game
-- information is not Nothing. See also
-- http://www.red-bean.com/sgf/hex.html#IP
type GameInfoHex = Bool
-- | See also GameTree and
-- http://www.red-bean.com/sgf/hex.html#IS
data ViewerSetting
-- | Identify future moves that have been tried?
Tried :: ViewerSetting
-- | Show good/bad move markings?
Marked :: ViewerSetting
-- | Identify the last cell played?
LastMove :: ViewerSetting
-- | Display column/row headings?
Headings :: ViewerSetting
-- | Lock the game against new moves?
Lock :: ViewerSetting
-- | See also TreeOcti and Game.
type NodeOcti = GameNode () () RuleSetOcti GameInfoOcti ()
-- | See also RuleSet, GameInfo, and
-- http://red-bean.com/sgf/octi.html#RU
data RuleSetOcti
OctiRuleSet :: MajorVariation -> (Set MinorVariation) -> RuleSetOcti
-- | See also NodeOcti and the otherGameInfo field of
-- GameInfo.
data GameInfoOcti
GameInfoOcti :: Set Point -> Set Point -> Integer -> Integer -> Integer -> GameInfoOcti
-- | Black should be set up with one empty pod on each of these points. An
-- empty set indicates that this property was not specified. See also
-- http://www.red-bean.com/sgf/octi.html#BO
squaresWhite :: GameInfoOcti -> Set Point
-- | White should be set up with one empty pod on each of these points. An
-- empty set indicates that this property was not specified. See also
-- http://www.red-bean.com/sgf/octi.html#WO
squaresBlack :: GameInfoOcti -> Set Point
-- | How many prongs each player starts with. See also
-- http://www.red-bean.com/sgf/octi.html#NP
prongs :: GameInfoOcti -> Integer
-- | How many pods each player has in reserve to start with. See also
-- http://www.red-bean.com/sgf/octi.html#NR
reserve :: GameInfoOcti -> Integer
-- | How many superprongs each player starts with. See also
-- http://www.red-bean.com/sgf/octi.html#NS
superProngs :: GameInfoOcti -> Integer
-- | See also RuleSetOcti.
data MajorVariation
Full :: MajorVariation
Fast :: MajorVariation
Kids :: MajorVariation
-- | See also RuleSetOcti.
data MinorVariation
Edgeless :: MinorVariation
Superprong :: MinorVariation
OtherMinorVariation :: String -> MinorVariation
-- | See also TreeOther and Game.
type NodeOther = GameNode [Word8] [Word8] Void () ()
type Collection = [Game]
-- | 0-indexed x/y coordinates that start at the top left
type Point = (Integer, Integer)
-- | See also Game.
type Application = String
-- | See also Game.
type Version = String
-- | See also Game.
type AutoMarkup = Bool
-- | See also GameTree.
type TreeGo = Tree NodeGo
-- | See also GameTree.
type TreeBackgammon = Tree NodeBackgammon
-- | See also GameTree.
type TreeLinesOfAction = Tree NodeLinesOfAction
-- | See also GameTree.
type TreeHex = Tree NodeHex
-- | See also GameTree.
type TreeOcti = Tree NodeOcti
-- | See also GameTree.
type TreeOther = Tree NodeOther
data Color
Black :: Color
White :: Color
-- | See also Rank. In addition to the standard "kyu" and "dan"
-- ranks, this also supports the non-standard (but common) "pro" ranks.
data RankScale
Kyu :: RankScale
Dan :: RankScale
Pro :: RankScale
data Emphasis
Normal :: Emphasis
Strong :: Emphasis
-- | See also Rank.
data Certainty
Uncertain :: Certainty
Certain :: Certainty
-- | See also Move.
data FuzzyBool
Possibly :: FuzzyBool
Definitely :: FuzzyBool
-- | See also GameTree. This enumeration is used for the GM property
-- (see http://www.red-bean.com/sgf/properties.html#GM). The Enum
-- instance converts to and from the numeric game codes listed there.
data GameType
Go :: GameType
Othello :: GameType
Chess :: GameType
Gomoku :: GameType
NineMen'sMorris :: GameType
Backgammon :: GameType
ChineseChess :: GameType
Shogi :: GameType
LinesOfAction :: GameType
Ataxx :: GameType
Hex :: GameType
Jungle :: GameType
Neutron :: GameType
Philosopher'sFootball :: GameType
Quadrature :: GameType
Trax :: GameType
Tantrix :: GameType
Amazons :: GameType
Octi :: GameType
Gess :: GameType
Twixt :: GameType
Zertz :: GameType
Plateau :: GameType
Yinsh :: GameType
Punct :: GameType
Gobblet :: GameType
Hive :: GameType
Exxit :: GameType
Hnefatal :: GameType
Kuba :: GameType
Tripples :: GameType
Chase :: GameType
TumblingDown :: GameType
Sahara :: GameType
Byte :: GameType
Focus :: GameType
Dvonn :: GameType
Tamsk :: GameType
Gipf :: GameType
Kropki :: GameType
-- | See also Annotation.
data Judgment
GoodForWhite :: Judgment
GoodForBlack :: Judgment
Even :: Judgment
Unclear :: Judgment
-- | See also Move.
data Quality
Bad :: Emphasis -> Quality
Doubtful :: Quality
Interesting :: Quality
Good :: Emphasis -> Quality
-- | See also Markup. With the exception of Selected, the
-- constructor names describe a shape whose outline should be shown over
-- the given point.
data Mark
Circle :: Mark
X :: Mark
-- | The exact appearance of this kind of markup is not specified, though
-- suggestions include darkening the colors on these points or inverting
-- the colors on these points.
Selected :: Mark
Square :: Mark
Triangle :: Mark
-- | See also Markup.
data Numbering
-- | Don't print move numbers.
Unnumbered :: Numbering
-- | Print move numbers as they are.
Numbered :: Numbering
-- | Subtract enough multiples of 100 from each move number that the first
-- labeled move is below 100.
Modulo100 :: Numbering
-- | See also Game.
data VariationType
-- | Variations are stored in child nodes.
Children :: VariationType
-- | Variations are stored in sibling nodes.
Siblings :: VariationType
-- | See also Figure.
data FigureFlag
-- | Show coordinates around the edges of the board.
Coordinates :: FigureFlag
-- | Show the diagram's name.
Name :: FigureFlag
-- | List moves that can't be shown in the diagram as text.
HiddenMoves :: FigureFlag
-- | Remove captured stones from the diagram.
RemoveCaptures :: FigureFlag
-- | Show hoshi dots.
Hoshi :: FigureFlag
-- | See also GameResult. Games that end normally use Score
-- if there is a natural concept of score differential for that game and
-- OtherWinType if not.
data WinType
Score :: Rational -> WinType
Resign :: WinType
Time :: WinType
Forfeit :: WinType
OtherWinType :: WinType
-- | See also GameInfo.
data GameResult
Draw :: GameResult
Void :: GameResult
Unknown :: GameResult
-- | The first argument is the color of the winner.
Win :: Color -> WinType -> GameResult
-- | See also GameInfo, especially the rankBlack and
-- rankWhite fields. The Eq and Ord instances
-- are the derived ones, and should not be mistaken for semantic equality
-- or ordering.
data Rank
-- | Ranked in one of the standard ways. Most SGF generators specify the
-- certainty only when it is Uncertain. Therefore, it may be
-- reasonable to treat Nothing and Just Certain
-- identically.
Ranked :: Integer -> RankScale -> (Maybe Certainty) -> Rank
-- | Any rank that does not fall in the standard categories. This field
-- must not contain newlines.
OtherRank :: String -> Rank
-- | See also GameInfo. Typical values for the a type
-- variable are RuleSetGo, RuleSetBackgammon, and
-- RuleSetOcti. For games where the valid values of the ruleset
-- field is not specified, the a type variable will be
-- Void to ensure that all rulesets are specified as a
-- String.
data RuleSet a
Known :: !a -> RuleSet a
OtherRuleSet :: String -> RuleSet a
-- | See also GameInfo.
data Round
-- | Only a round number is given.
SimpleRound :: Integer -> Round
-- | Both a round number and a type, like "final", "playoff", or "league".
FormattedRound :: Integer -> String -> Round
-- | Round information in an unknown format.
OtherRound :: String -> Round
-- | See also GameInfo.
data PartialDate
Year :: Integer -> PartialDate
year :: PartialDate -> Integer
Month :: Integer -> Integer -> PartialDate
year :: PartialDate -> Integer
month :: PartialDate -> Integer
Day :: Integer -> Integer -> Integer -> PartialDate
year :: PartialDate -> Integer
month :: PartialDate -> Integer
day :: PartialDate -> Integer
-- | See also Markup.
data Figure
-- | Unnamed figure using the application default settings.
DefaultFigure :: Figure
-- | Named figure using the application default settings.
NamedDefaultFigure :: String -> Figure
-- | Named figure that overrides the application's figure settings.
NamedFigure :: String -> (FigureFlag -> Bool) -> Figure
-- | A type with no constructors used merely to indicate a lack of data.
data Void
instance (Eq move, Eq stone, Eq ruleSet, Eq extraGameInfo, Eq extraAnnotation) => Eq (GameNode move stone ruleSet extraGameInfo extraAnnotation)
instance (Ord move, Ord stone, Ord ruleSet, Ord extraGameInfo, Ord extraAnnotation) => Ord (GameNode move stone ruleSet extraGameInfo extraAnnotation)
instance (Show move, Show stone, Show ruleSet, Show extraGameInfo, Show extraAnnotation) => Show (GameNode move stone ruleSet extraGameInfo extraAnnotation)
instance (Ord stone, Read move, Read stone, Read ruleSet, Read extraGameInfo, Read extraAnnotation) => Read (GameNode move stone ruleSet extraGameInfo extraAnnotation)
instance Eq GameTree
instance Show GameTree
instance Read GameTree
instance Eq Game
instance Show Game
instance Read Game
instance Eq Markup
instance Ord Markup
instance Show Markup
instance Read Markup
instance (Eq extra) => Eq (Annotation extra)
instance (Ord extra) => Ord (Annotation extra)
instance (Show extra) => Show (Annotation extra)
instance (Read extra) => Read (Annotation extra)
instance Eq GameInfoOcti
instance Ord GameInfoOcti
instance Show GameInfoOcti
instance Read GameInfoOcti
instance Eq GameInfoLinesOfAction
instance Ord GameInfoLinesOfAction
instance Show GameInfoLinesOfAction
instance Read GameInfoLinesOfAction
instance Eq GameInfoGo
instance Ord GameInfoGo
instance Show GameInfoGo
instance Read GameInfoGo
instance (Eq ruleSet, Eq extra) => Eq (GameInfo ruleSet extra)
instance (Ord ruleSet, Ord extra) => Ord (GameInfo ruleSet extra)
instance (Show ruleSet, Show extra) => Show (GameInfo ruleSet extra)
instance (Read ruleSet, Read extra) => Read (GameInfo ruleSet extra)
instance (Eq stone) => Eq (Setup stone)
instance (Ord stone) => Ord (Setup stone)
instance (Show stone) => Show (Setup stone)
instance (Ord stone, Read stone) => Read (Setup stone)
instance Eq MoveGo
instance Ord MoveGo
instance Show MoveGo
instance Read MoveGo
instance (Eq move) => Eq (Move move)
instance (Ord move) => Ord (Move move)
instance (Show move) => Show (Move move)
instance (Read move) => Read (Move move)
instance Eq Figure
instance Ord Figure
instance Show Figure
instance Read Figure
instance Eq FigureFlag
instance Ord FigureFlag
instance Show FigureFlag
instance Read FigureFlag
instance Bounded FigureFlag
instance Eq PartialDate
instance Ord PartialDate
instance Show PartialDate
instance Read PartialDate
instance Eq MatchInfo
instance Ord MatchInfo
instance Show MatchInfo
instance Read MatchInfo
instance Eq Round
instance Ord Round
instance Show Round
instance Read Round
instance Eq Rank
instance Ord Rank
instance Show Rank
instance Read Rank
instance Eq GameResult
instance Ord GameResult
instance Show GameResult
instance Read GameResult
instance Eq Quality
instance Ord Quality
instance Show Quality
instance Read Quality
instance Eq WinType
instance Ord WinType
instance Show WinType
instance Read WinType
instance (Eq a) => Eq (RuleSet a)
instance (Ord a) => Ord (RuleSet a)
instance (Show a) => Show (RuleSet a)
instance (Read a) => Read (RuleSet a)
instance Eq MinorVariation
instance Ord MinorVariation
instance Show MinorVariation
instance Read MinorVariation
instance Eq MajorVariation
instance Ord MajorVariation
instance Show MajorVariation
instance Read MajorVariation
instance Enum MajorVariation
instance Bounded MajorVariation
instance Eq RuleSetOcti
instance Ord RuleSetOcti
instance Show RuleSetOcti
instance Read RuleSetOcti
instance Eq RuleSetBackgammon
instance Ord RuleSetBackgammon
instance Show RuleSetBackgammon
instance Read RuleSetBackgammon
instance Enum RuleSetBackgammon
instance Bounded RuleSetBackgammon
instance Eq RuleSetGo
instance Ord RuleSetGo
instance Show RuleSetGo
instance Read RuleSetGo
instance Enum RuleSetGo
instance Bounded RuleSetGo
instance Eq Numbering
instance Ord Numbering
instance Show Numbering
instance Read Numbering
instance Enum Numbering
instance Bounded Numbering
instance Eq ViewerSetting
instance Ord ViewerSetting
instance Show ViewerSetting
instance Read ViewerSetting
instance Enum ViewerSetting
instance Bounded ViewerSetting
instance Eq GameInfoType
instance Ord GameInfoType
instance Show GameInfoType
instance Read GameInfoType
instance Eq Mark
instance Ord Mark
instance Show Mark
instance Read Mark
instance Enum Mark
instance Bounded Mark
instance Eq VariationType
instance Ord VariationType
instance Show VariationType
instance Read VariationType
instance Enum VariationType
instance Bounded VariationType
instance Eq InitialPlacement
instance Ord InitialPlacement
instance Show InitialPlacement
instance Read InitialPlacement
instance Enum InitialPlacement
instance Bounded InitialPlacement
instance Eq Judgment
instance Ord Judgment
instance Show Judgment
instance Read Judgment
instance Enum Judgment
instance Bounded Judgment
instance Eq RankScale
instance Ord RankScale
instance Show RankScale
instance Read RankScale
instance Enum RankScale
instance Bounded RankScale
instance Eq InitialPosition
instance Ord InitialPosition
instance Show InitialPosition
instance Read InitialPosition
instance Enum InitialPosition
instance Bounded InitialPosition
instance Eq Certainty
instance Ord Certainty
instance Show Certainty
instance Read Certainty
instance Enum Certainty
instance Bounded Certainty
instance Eq Color
instance Ord Color
instance Show Color
instance Read Color
instance Enum Color
instance Bounded Color
instance Eq Emphasis
instance Ord Emphasis
instance Show Emphasis
instance Read Emphasis
instance Enum Emphasis
instance Bounded Emphasis
instance Eq FuzzyBool
instance Ord FuzzyBool
instance Show FuzzyBool
instance Read FuzzyBool
instance Enum FuzzyBool
instance Bounded FuzzyBool
instance Eq GameType
instance Ord GameType
instance Bounded GameType
instance Show GameType
instance Read GameType
instance (Bounded k, Enum k, Ord k, Ord v) => Ord (k -> v)
instance (Bounded k, Enum k, Ord k, Eq v) => Eq (k -> v)
instance (Bounded k, Enum k, Ord k, Read k, Read v) => Read (k -> v)
instance (Bounded k, Enum k, Ord k, Show k, Show v) => Show (k -> v)
instance Enum FigureFlag
instance Bounded GameInfoType
instance Enum GameInfoType
instance Enum GameType
instance Show Void
instance Read Void
instance Ord Void
instance Eq Void
module Data.SGF.Parse
-- | Parse a Word8 stream into an SGF collection. A collection is a
-- list of games; the documentation for Game has more details.
-- There are generally two kinds of errors in SGF files: recoverable ones
-- (which will be accumulated in the [Warning] return) and
-- unrecoverable ones (which will result in parse errors).
collection :: (Stream s m Word8) => ParsecT s u m (Collection, [Warning])
-- | Clip to a valid, representable date. Years are clipped to the
-- 0000-9999 range; months are clipped to the 1-12 range, and days are
-- clipped to the 1-<number of days in the given month> range
-- (accounting for leap years in the case of February).
--
-- If a parsed date is changed by this function, a warning is emitted.
clipDate :: PartialDate -> PartialDate
-- | Types of properties, as given in the SGF specification.
data PropertyType
Move :: PropertyType
Setup :: PropertyType
Root :: PropertyType
GameInfo :: PropertyType
-- | Technically, these properties have type "none" and attribute
-- "inherit", but the property index lists them as properties of type
-- "inherit" with no attributes, so we follow that lead.
Inherit :: PropertyType
None :: PropertyType
-- | All properties of each type listed in the SGF specification.
properties :: GameType -> PropertyType -> [String]
-- | Just the properties associated with specific games.
extraProperties :: GameType -> PropertyType -> [String]
data Property
Property :: SourcePos -> String -> [[Word8]] -> Property
-- | Currently, this is pretty lame: it doesn't track line number and
-- character number, only byte offset from the beginning of the file.
-- This is because I don't really understand how to correctly track line
-- number and character number properly in the face of dynamically
-- changing encodings, whereas byte number is a totally braindead
-- statistic to track.
position :: Property -> SourcePos
-- | The literal name of the property. This is guaranteed to be a non-empty
-- string of upper-case ASCII characters.
name :: Property -> String
-- | The arguments to the property.
values :: Property -> [[Word8]]
-- | Warnings signify recoverable errors.
data Warning
DuplicatePropertyOmitted :: Property -> Warning
SquareSizeSpecifiedAsRectangle :: SourcePos -> Warning
DanglingEscapeCharacterOmitted :: SourcePos -> Warning
PropValueForNonePropertyOmitted :: Property -> Warning
UnknownPropertyPreserved :: String -> Warning
PointSpecifiedAsPointRange :: Property -> Warning
DuplicatePointsOmitted :: Property -> [Point] -> Warning
InvalidDatesClipped :: (Set PartialDate) -> Warning
AnnotationWithNoMoveOmitted :: Property -> Warning
ExtraGameInfoOmitted :: Property -> Warning
NestedRootPropertyOmitted :: Property -> Warning
MovelessAnnotationOmitted :: Property -> Warning
DuplicateSetupOperationsOmitted :: [Point] -> Warning
ExtraPositionalJudgmentOmitted :: (Judgment, Emphasis) -> Warning
DuplicateMarkupOmitted :: (Mark, Point) -> Warning
ExtraPropertyValuesOmitted :: Property -> Warning
DuplicateLabelOmitted :: (Point, String) -> Warning
UnknownNumberingIgnored :: Integer -> Warning
data ErrorType
UnknownEncoding :: ErrorType
AmbiguousEncoding :: ErrorType
FormatUnsupported :: ErrorType
GameUnsupported :: ErrorType
OutOfBounds :: ErrorType
BadlyFormattedValue :: ErrorType
BadlyEncodedValue :: ErrorType
ConcurrentMoveAndSetup :: ErrorType
ConcurrentBlackAndWhiteMove :: ErrorType
ConcurrentAnnotations :: ErrorType
ExtraMoveAnnotations :: ErrorType
data Error
KnownError :: ErrorType -> SourcePos -> Error
errorType :: Error -> ErrorType
errorPosition :: Error -> SourcePos
UnknownError :: Maybe String -> Error
errorDescription :: Error -> Maybe String
instance Eq PropertyType
instance Ord PropertyType
instance Show PropertyType
instance Read PropertyType
instance Enum PropertyType
instance Bounded PropertyType
-- | This is a parser for the go/igo/weiqi/baduk fragment of the SGF
-- format. Encodings latin-1, utf-8, and ascii are supported, and the
-- parser strives to be robust to minor errors, especially those made by
-- the most common SGF editors. There are plans to support other games
-- and pretty-printing in future releases.
module Data.SGF