-- 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.3.2 -- | 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 GameTree 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 GameTree 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 GameTree 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 GameTree 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 GameTree 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 GameTree 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 GHC.Read.Read Data.SGF.Types.GameType instance GHC.Show.Show Data.SGF.Types.GameType instance GHC.Enum.Bounded Data.SGF.Types.GameType instance GHC.Classes.Ord Data.SGF.Types.GameType instance GHC.Classes.Eq Data.SGF.Types.GameType instance GHC.Enum.Bounded Data.SGF.Types.FuzzyBool instance GHC.Enum.Enum Data.SGF.Types.FuzzyBool instance GHC.Read.Read Data.SGF.Types.FuzzyBool instance GHC.Show.Show Data.SGF.Types.FuzzyBool instance GHC.Classes.Ord Data.SGF.Types.FuzzyBool instance GHC.Classes.Eq Data.SGF.Types.FuzzyBool instance GHC.Enum.Bounded Data.SGF.Types.Emphasis instance GHC.Enum.Enum Data.SGF.Types.Emphasis instance GHC.Read.Read Data.SGF.Types.Emphasis instance GHC.Show.Show Data.SGF.Types.Emphasis instance GHC.Classes.Ord Data.SGF.Types.Emphasis instance GHC.Classes.Eq Data.SGF.Types.Emphasis instance GHC.Enum.Bounded Data.SGF.Types.Color instance GHC.Enum.Enum Data.SGF.Types.Color instance GHC.Read.Read Data.SGF.Types.Color instance GHC.Show.Show Data.SGF.Types.Color instance GHC.Classes.Ord Data.SGF.Types.Color instance GHC.Classes.Eq Data.SGF.Types.Color instance GHC.Enum.Bounded Data.SGF.Types.Certainty instance GHC.Enum.Enum Data.SGF.Types.Certainty instance GHC.Read.Read Data.SGF.Types.Certainty instance GHC.Show.Show Data.SGF.Types.Certainty instance GHC.Classes.Ord Data.SGF.Types.Certainty instance GHC.Classes.Eq Data.SGF.Types.Certainty instance GHC.Enum.Bounded Data.SGF.Types.InitialPosition instance GHC.Enum.Enum Data.SGF.Types.InitialPosition instance GHC.Read.Read Data.SGF.Types.InitialPosition instance GHC.Show.Show Data.SGF.Types.InitialPosition instance GHC.Classes.Ord Data.SGF.Types.InitialPosition instance GHC.Classes.Eq Data.SGF.Types.InitialPosition instance GHC.Enum.Bounded Data.SGF.Types.RankScale instance GHC.Enum.Enum Data.SGF.Types.RankScale instance GHC.Read.Read Data.SGF.Types.RankScale instance GHC.Show.Show Data.SGF.Types.RankScale instance GHC.Classes.Ord Data.SGF.Types.RankScale instance GHC.Classes.Eq Data.SGF.Types.RankScale instance GHC.Enum.Bounded Data.SGF.Types.Judgment instance GHC.Enum.Enum Data.SGF.Types.Judgment instance GHC.Read.Read Data.SGF.Types.Judgment instance GHC.Show.Show Data.SGF.Types.Judgment instance GHC.Classes.Ord Data.SGF.Types.Judgment instance GHC.Classes.Eq Data.SGF.Types.Judgment instance GHC.Enum.Bounded Data.SGF.Types.InitialPlacement instance GHC.Enum.Enum Data.SGF.Types.InitialPlacement instance GHC.Read.Read Data.SGF.Types.InitialPlacement instance GHC.Show.Show Data.SGF.Types.InitialPlacement instance GHC.Classes.Ord Data.SGF.Types.InitialPlacement instance GHC.Classes.Eq Data.SGF.Types.InitialPlacement instance GHC.Enum.Bounded Data.SGF.Types.VariationType instance GHC.Enum.Enum Data.SGF.Types.VariationType instance GHC.Read.Read Data.SGF.Types.VariationType instance GHC.Show.Show Data.SGF.Types.VariationType instance GHC.Classes.Ord Data.SGF.Types.VariationType instance GHC.Classes.Eq Data.SGF.Types.VariationType instance GHC.Enum.Bounded Data.SGF.Types.Mark instance GHC.Enum.Enum Data.SGF.Types.Mark instance GHC.Read.Read Data.SGF.Types.Mark instance GHC.Show.Show Data.SGF.Types.Mark instance GHC.Classes.Ord Data.SGF.Types.Mark instance GHC.Classes.Eq Data.SGF.Types.Mark instance GHC.Read.Read Data.SGF.Types.GameInfoType instance GHC.Show.Show Data.SGF.Types.GameInfoType instance GHC.Classes.Ord Data.SGF.Types.GameInfoType instance GHC.Classes.Eq Data.SGF.Types.GameInfoType instance GHC.Enum.Bounded Data.SGF.Types.ViewerSetting instance GHC.Enum.Enum Data.SGF.Types.ViewerSetting instance GHC.Read.Read Data.SGF.Types.ViewerSetting instance GHC.Show.Show Data.SGF.Types.ViewerSetting instance GHC.Classes.Ord Data.SGF.Types.ViewerSetting instance GHC.Classes.Eq Data.SGF.Types.ViewerSetting instance GHC.Enum.Bounded Data.SGF.Types.Numbering instance GHC.Enum.Enum Data.SGF.Types.Numbering instance GHC.Read.Read Data.SGF.Types.Numbering instance GHC.Show.Show Data.SGF.Types.Numbering instance GHC.Classes.Ord Data.SGF.Types.Numbering instance GHC.Classes.Eq Data.SGF.Types.Numbering instance GHC.Enum.Bounded Data.SGF.Types.RuleSetGo instance GHC.Enum.Enum Data.SGF.Types.RuleSetGo instance GHC.Read.Read Data.SGF.Types.RuleSetGo instance GHC.Show.Show Data.SGF.Types.RuleSetGo instance GHC.Classes.Ord Data.SGF.Types.RuleSetGo instance GHC.Classes.Eq Data.SGF.Types.RuleSetGo instance GHC.Enum.Bounded Data.SGF.Types.RuleSetBackgammon instance GHC.Enum.Enum Data.SGF.Types.RuleSetBackgammon instance GHC.Read.Read Data.SGF.Types.RuleSetBackgammon instance GHC.Show.Show Data.SGF.Types.RuleSetBackgammon instance GHC.Classes.Ord Data.SGF.Types.RuleSetBackgammon instance GHC.Classes.Eq Data.SGF.Types.RuleSetBackgammon instance GHC.Enum.Bounded Data.SGF.Types.MajorVariation instance GHC.Enum.Enum Data.SGF.Types.MajorVariation instance GHC.Read.Read Data.SGF.Types.MajorVariation instance GHC.Show.Show Data.SGF.Types.MajorVariation instance GHC.Classes.Ord Data.SGF.Types.MajorVariation instance GHC.Classes.Eq Data.SGF.Types.MajorVariation instance GHC.Read.Read Data.SGF.Types.MinorVariation instance GHC.Show.Show Data.SGF.Types.MinorVariation instance GHC.Classes.Ord Data.SGF.Types.MinorVariation instance GHC.Classes.Eq Data.SGF.Types.MinorVariation instance GHC.Read.Read Data.SGF.Types.RuleSetOcti instance GHC.Show.Show Data.SGF.Types.RuleSetOcti instance GHC.Classes.Ord Data.SGF.Types.RuleSetOcti instance GHC.Classes.Eq Data.SGF.Types.RuleSetOcti instance GHC.Read.Read a => GHC.Read.Read (Data.SGF.Types.RuleSet a) instance GHC.Show.Show a => GHC.Show.Show (Data.SGF.Types.RuleSet a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.SGF.Types.RuleSet a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.SGF.Types.RuleSet a) instance GHC.Read.Read Data.SGF.Types.WinType instance GHC.Show.Show Data.SGF.Types.WinType instance GHC.Classes.Ord Data.SGF.Types.WinType instance GHC.Classes.Eq Data.SGF.Types.WinType instance GHC.Read.Read Data.SGF.Types.Quality instance GHC.Show.Show Data.SGF.Types.Quality instance GHC.Classes.Ord Data.SGF.Types.Quality instance GHC.Classes.Eq Data.SGF.Types.Quality instance GHC.Read.Read Data.SGF.Types.GameResult instance GHC.Show.Show Data.SGF.Types.GameResult instance GHC.Classes.Ord Data.SGF.Types.GameResult instance GHC.Classes.Eq Data.SGF.Types.GameResult instance GHC.Read.Read Data.SGF.Types.Rank instance GHC.Show.Show Data.SGF.Types.Rank instance GHC.Classes.Ord Data.SGF.Types.Rank instance GHC.Classes.Eq Data.SGF.Types.Rank instance GHC.Read.Read Data.SGF.Types.Round instance GHC.Show.Show Data.SGF.Types.Round instance GHC.Classes.Ord Data.SGF.Types.Round instance GHC.Classes.Eq Data.SGF.Types.Round instance GHC.Read.Read Data.SGF.Types.MatchInfo instance GHC.Show.Show Data.SGF.Types.MatchInfo instance GHC.Classes.Ord Data.SGF.Types.MatchInfo instance GHC.Classes.Eq Data.SGF.Types.MatchInfo instance GHC.Read.Read Data.SGF.Types.PartialDate instance GHC.Show.Show Data.SGF.Types.PartialDate instance GHC.Classes.Ord Data.SGF.Types.PartialDate instance GHC.Classes.Eq Data.SGF.Types.PartialDate instance GHC.Enum.Bounded Data.SGF.Types.FigureFlag instance GHC.Read.Read Data.SGF.Types.FigureFlag instance GHC.Show.Show Data.SGF.Types.FigureFlag instance GHC.Classes.Ord Data.SGF.Types.FigureFlag instance GHC.Classes.Eq Data.SGF.Types.FigureFlag instance GHC.Read.Read Data.SGF.Types.Figure instance GHC.Show.Show Data.SGF.Types.Figure instance GHC.Classes.Ord Data.SGF.Types.Figure instance GHC.Classes.Eq Data.SGF.Types.Figure instance GHC.Read.Read move => GHC.Read.Read (Data.SGF.Types.Move move) instance GHC.Show.Show move => GHC.Show.Show (Data.SGF.Types.Move move) instance GHC.Classes.Ord move => GHC.Classes.Ord (Data.SGF.Types.Move move) instance GHC.Classes.Eq move => GHC.Classes.Eq (Data.SGF.Types.Move move) instance GHC.Read.Read Data.SGF.Types.MoveGo instance GHC.Show.Show Data.SGF.Types.MoveGo instance GHC.Classes.Ord Data.SGF.Types.MoveGo instance GHC.Classes.Eq Data.SGF.Types.MoveGo instance (GHC.Read.Read stone, GHC.Classes.Ord stone) => GHC.Read.Read (Data.SGF.Types.Setup stone) instance GHC.Show.Show stone => GHC.Show.Show (Data.SGF.Types.Setup stone) instance GHC.Classes.Ord stone => GHC.Classes.Ord (Data.SGF.Types.Setup stone) instance GHC.Classes.Eq stone => GHC.Classes.Eq (Data.SGF.Types.Setup stone) instance (GHC.Read.Read ruleSet, GHC.Read.Read extra) => GHC.Read.Read (Data.SGF.Types.GameInfo ruleSet extra) instance (GHC.Show.Show ruleSet, GHC.Show.Show extra) => GHC.Show.Show (Data.SGF.Types.GameInfo ruleSet extra) instance (GHC.Classes.Ord ruleSet, GHC.Classes.Ord extra) => GHC.Classes.Ord (Data.SGF.Types.GameInfo ruleSet extra) instance (GHC.Classes.Eq ruleSet, GHC.Classes.Eq extra) => GHC.Classes.Eq (Data.SGF.Types.GameInfo ruleSet extra) instance GHC.Read.Read Data.SGF.Types.GameInfoGo instance GHC.Show.Show Data.SGF.Types.GameInfoGo instance GHC.Classes.Ord Data.SGF.Types.GameInfoGo instance GHC.Classes.Eq Data.SGF.Types.GameInfoGo instance GHC.Read.Read Data.SGF.Types.GameInfoLinesOfAction instance GHC.Show.Show Data.SGF.Types.GameInfoLinesOfAction instance GHC.Classes.Ord Data.SGF.Types.GameInfoLinesOfAction instance GHC.Classes.Eq Data.SGF.Types.GameInfoLinesOfAction instance GHC.Read.Read Data.SGF.Types.GameInfoOcti instance GHC.Show.Show Data.SGF.Types.GameInfoOcti instance GHC.Classes.Ord Data.SGF.Types.GameInfoOcti instance GHC.Classes.Eq Data.SGF.Types.GameInfoOcti instance GHC.Read.Read extra => GHC.Read.Read (Data.SGF.Types.Annotation extra) instance GHC.Show.Show extra => GHC.Show.Show (Data.SGF.Types.Annotation extra) instance GHC.Classes.Ord extra => GHC.Classes.Ord (Data.SGF.Types.Annotation extra) instance GHC.Classes.Eq extra => GHC.Classes.Eq (Data.SGF.Types.Annotation extra) instance GHC.Read.Read Data.SGF.Types.Markup instance GHC.Show.Show Data.SGF.Types.Markup instance GHC.Classes.Ord Data.SGF.Types.Markup instance GHC.Classes.Eq Data.SGF.Types.Markup instance (GHC.Classes.Ord stone, GHC.Read.Read ruleSet, GHC.Read.Read extraGameInfo, GHC.Read.Read stone, GHC.Read.Read move, GHC.Read.Read extraAnnotation) => GHC.Read.Read (Data.SGF.Types.GameNode move stone ruleSet extraGameInfo extraAnnotation) instance (GHC.Show.Show ruleSet, GHC.Show.Show extraGameInfo, GHC.Show.Show stone, GHC.Show.Show move, GHC.Show.Show extraAnnotation) => GHC.Show.Show (Data.SGF.Types.GameNode move stone ruleSet extraGameInfo extraAnnotation) instance (GHC.Classes.Ord ruleSet, GHC.Classes.Ord extraGameInfo, GHC.Classes.Ord stone, GHC.Classes.Ord move, GHC.Classes.Ord extraAnnotation) => GHC.Classes.Ord (Data.SGF.Types.GameNode move stone ruleSet extraGameInfo extraAnnotation) instance (GHC.Classes.Eq ruleSet, GHC.Classes.Eq extraGameInfo, GHC.Classes.Eq stone, GHC.Classes.Eq move, GHC.Classes.Eq extraAnnotation) => GHC.Classes.Eq (Data.SGF.Types.GameNode move stone ruleSet extraGameInfo extraAnnotation) instance GHC.Read.Read Data.SGF.Types.GameTree instance GHC.Show.Show Data.SGF.Types.GameTree instance GHC.Classes.Eq Data.SGF.Types.GameTree instance GHC.Read.Read Data.SGF.Types.Game instance GHC.Show.Show Data.SGF.Types.Game instance GHC.Classes.Eq Data.SGF.Types.Game instance GHC.Enum.Enum Data.SGF.Types.FigureFlag instance GHC.Enum.Enum Data.SGF.Types.GameInfoType instance GHC.Enum.Bounded Data.SGF.Types.GameInfoType instance GHC.Enum.Enum Data.SGF.Types.GameType instance GHC.Classes.Eq Data.SGF.Types.Void instance GHC.Classes.Ord Data.SGF.Types.Void instance GHC.Read.Read Data.SGF.Types.Void instance GHC.Show.Show Data.SGF.Types.Void instance (GHC.Enum.Bounded k, GHC.Enum.Enum k, GHC.Classes.Ord k, GHC.Show.Show k, GHC.Show.Show v) => GHC.Show.Show (k -> v) instance (GHC.Enum.Bounded k, GHC.Enum.Enum k, GHC.Classes.Ord k, GHC.Read.Read k, GHC.Read.Read v) => GHC.Read.Read (k -> v) instance (GHC.Enum.Bounded k, GHC.Enum.Enum k, GHC.Classes.Ord k, GHC.Classes.Eq v) => GHC.Classes.Eq (k -> v) instance (GHC.Enum.Bounded k, GHC.Enum.Enum k, GHC.Classes.Ord k, GHC.Classes.Ord v) => GHC.Classes.Ord (k -> v) 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 GHC.Enum.Bounded Data.SGF.Parse.PropertyType instance GHC.Enum.Enum Data.SGF.Parse.PropertyType instance GHC.Read.Read Data.SGF.Parse.PropertyType instance GHC.Show.Show Data.SGF.Parse.PropertyType instance GHC.Classes.Ord Data.SGF.Parse.PropertyType instance GHC.Classes.Eq Data.SGF.Parse.PropertyType instance Control.Monad.Fail.MonadFail (Data.Either.Either Data.SGF.Parse.Util.Error) -- | 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 -- | 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]) runParser :: GenParser tok st a -> st -> SourceName -> [tok] -> Either ParseError a