goatee 0.3.1.2 → 0.3.1.3
raw patch · 33 files changed
+45/−42 lines, 33 filesdep ~HUnitdep ~template-haskellsetup-changedPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: HUnit, template-haskell
API changes (from Hackage documentation)
+ Game.Goatee.Lib.Property.Parser: instance GHC.Base.Semigroup Game.Goatee.Lib.Property.Parser.CoordListMonoid
- Game.Goatee.Lib.Monad: class (Functor go, Applicative go, Monad go) => MonadGo go where getCoordState coord = liftM (boardCoordState coord . cursorBoard) getCursor getProperties = liftM cursorProperties getCursor getPropertyValue descriptor = liftM (liftM $ propertyValue descriptor) $ getProperty descriptor putProperty property = modifyProperty property $ const $ Just property deleteProperty descriptor = modifyProperty descriptor $ const Nothing modifyPropertyValue descriptor fn = modifyProperty descriptor $ \ old -> propertyBuilder descriptor <$> fn (propertyValue descriptor <$> old) modifyPropertyString descriptor fn = modifyPropertyValue descriptor $ \ value -> case fn (maybe "" sgfToString value) of { "" -> Nothing str -> let sgf = stringToSgf str in if null $ sgfToString sgf then Nothing else Just sgf } modifyPropertyList descriptor fn = modifyPropertyValue descriptor $ \ value -> case fn $ fromMaybe [] value of { [] -> Nothing value' -> Just value' } modifyPropertyCoords descriptor fn = modifyPropertyValue descriptor $ \ value -> case fn $ maybe [] expandCoordList value of { [] -> Nothing coords -> Just $ buildCoordList coords } getAssignedStone coord = fmap msum $ forM stoneAssignmentProperties $ \ descriptor -> ((\ coords -> if coord `elem` coords then Just $ stoneAssignmentPropertyToStone descriptor else Nothing) <=< fmap expandCoordList) <$> getPropertyValue descriptor getAllAssignedStones = fmap unions $ forM stoneAssignmentProperties $ \ descriptor -> let stone = stoneAssignmentPropertyToStone descriptor in fromList . map (\ coord -> (coord, stone)) . maybe [] expandCoordList <$> getPropertyValue descriptor modifyAssignedStones coords f = do { needChild <- ((&&) <$> notElem SetupProperty <*> elem MoveProperty) . map propertyType <$> getProperties; if needChild then case f Nothing of { Nothing -> return () Just assignedStone -> do { addChild (emptyNode {nodeProperties = [propertyBuilder (stoneToStoneAssignmentProperty assignedStone) $ buildCoordList coords]}); ok <- goDown =<< subtract 1 . length . cursorChildren <$> getCursor; unless ok $ fail "GoT.modifyAssignedStones: Failed to move to new child." } } else do { allAssignedStones <- getAllAssignedStones; let allAssignedStones' = foldr (alter f) allAssignedStones coords byStone, byStone' :: Map (Maybe Color) [Coord] byStone = mapInvert allAssignedStones byStone' = mapInvert allAssignedStones' diff :: Map (Maybe Color) ([Coord], [Coord]) diff = mergeWithKey (\ _ oldCoords newCoords -> if newCoords == oldCoords then Nothing else Just (oldCoords, newCoords)) (map $ \ oldCoords -> (oldCoords, [])) (map $ \ newCoords -> ([], newCoords)) byStone byStone'; forM_ (assocs diff) $ \ (stone, (oldCoords, newCoords)) -> when (newCoords /= oldCoords) $ modifyPropertyCoords (stoneToStoneAssignmentProperty stone) $ const newCoords } } getMark = liftM coordMark . getCoordState modifyMark f coord = do { maybeOldMark <- getMark coord; case (maybeOldMark, f maybeOldMark) of { (Just oldMark, Nothing) -> remove oldMark (Nothing, Just newMark) -> add newMark (Just oldMark, Just newMark) | oldMark /= newMark -> remove oldMark >> add newMark (Just _, Just _) -> return () (Nothing, Nothing) -> return () } } where remove mark = modifyPropertyCoords (markProperty mark) (delete coord) add mark = modifyPropertyCoords (markProperty mark) (coord :) addChild node = do { childCount <- liftM (length . cursorChildren) getCursor; addChildAt childCount node } on0 event handler = on event $ eventHandlerFromAction event handler
+ Game.Goatee.Lib.Monad: class (Functor go, Applicative go, Monad go) => MonadGo go
- Game.Goatee.Lib.Property: ValuedPropertyInfo :: String -> PropertyType -> Bool -> (Property -> Bool) -> PropertyValueType v -> (Property -> v) -> (v -> Property) -> ValuedPropertyInfo v
+ Game.Goatee.Lib.Property: ValuedPropertyInfo :: String -> PropertyType -> Bool -> Property -> Bool -> PropertyValueType v -> Property -> v -> v -> Property -> ValuedPropertyInfo v
Files
- Setup.hs +1/−1
- goatee.cabal +4/−5
- src/Game/Goatee/App.hs +2/−2
- src/Game/Goatee/Common.hs +1/−1
- src/Game/Goatee/Common/Bigfloat.hs +1/−1
- src/Game/Goatee/Lib/Board.hs +1/−1
- src/Game/Goatee/Lib/Monad.hs +1/−1
- src/Game/Goatee/Lib/Parser.hs +1/−1
- src/Game/Goatee/Lib/Property.hs +1/−1
- src/Game/Goatee/Lib/Property/Base.hs +1/−1
- src/Game/Goatee/Lib/Property/Info.hs +1/−1
- src/Game/Goatee/Lib/Property/Parser.hs +8/−4
- src/Game/Goatee/Lib/Property/Renderer.hs +1/−1
- src/Game/Goatee/Lib/Property/Value.hs +1/−1
- src/Game/Goatee/Lib/Renderer.hs +1/−1
- src/Game/Goatee/Lib/Renderer/Tree.hs +1/−1
- src/Game/Goatee/Lib/Tree.hs +1/−1
- src/Game/Goatee/Lib/Types.hs +1/−1
- tests/Game/Goatee/Common/BigfloatTest.hs +1/−1
- tests/Game/Goatee/CommonTest.hs +2/−2
- tests/Game/Goatee/Lib/BoardTest.hs +1/−1
- tests/Game/Goatee/Lib/MonadTest.hs +1/−1
- tests/Game/Goatee/Lib/ParserTest.hs +1/−1
- tests/Game/Goatee/Lib/ParserTestUtils.hs +1/−1
- tests/Game/Goatee/Lib/Property/ParserTest.hs +1/−1
- tests/Game/Goatee/Lib/PropertyTest.hs +1/−1
- tests/Game/Goatee/Lib/RoundTripTest.hs +1/−1
- tests/Game/Goatee/Lib/TestInstances.hs +1/−1
- tests/Game/Goatee/Lib/TestUtils.hs +1/−1
- tests/Game/Goatee/Lib/TreeTest.hs +1/−1
- tests/Game/Goatee/Lib/TypesTest.hs +1/−1
- tests/Game/Goatee/Test/Common.hs +1/−1
- tests/Test.hs +1/−1
Setup.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
goatee.cabal view
@@ -1,10 +1,10 @@ name: goatee-version: 0.3.1.2+version: 0.3.1.3 synopsis: A monadic take on a 2,500-year-old board game - library. category: Game license: AGPL-3 license-file: LICENSE-copyright: Copyright 2014-2015 Bryan Gardiner+copyright: Copyright 2014-2018 Bryan Gardiner author: Bryan Gardiner <bog@khumba.net> maintainer: Bryan Gardiner <bog@khumba.net> homepage: http://khumba.net/projects/goatee@@ -32,7 +32,7 @@ containers >= 0.4 && < 0.6, mtl >= 2.1 && < 2.3, parsec >= 3.1 && < 3.2,- template-haskell >= 2.7 && < 2.12+ template-haskell >= 2.7 && < 2.14 exposed-modules: Game.Goatee.App Game.Goatee.Common@@ -67,7 +67,7 @@ base >= 4 && < 5, containers >= 0.4 && < 0.6, goatee,- HUnit >= 1.2 && < 1.4,+ HUnit >= 1.2 && < 1.7, mtl >= 2.1 && < 2.3, parsec >= 3.1 && < 3.2 ghc-options: -W -fwarn-incomplete-patterns -fwarn-unused-do-bind@@ -88,5 +88,4 @@ Game.Goatee.Lib.TreeTest Game.Goatee.Lib.TypesTest Game.Goatee.Test.Common- Test type: exitcode-stdio-1.0
src/Game/Goatee/App.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014-2015 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by@@ -29,7 +29,7 @@ -- | A user-presentable copyright message. applicationCopyright :: String-applicationCopyright = "Copyright 2014-2015 Bryan Gardiner"+applicationCopyright = "Copyright 2014-2018 Bryan Gardiner" -- | The home page for Goatee on the web. applicationWebsite :: String
src/Game/Goatee/Common.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
src/Game/Goatee/Common/Bigfloat.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
src/Game/Goatee/Lib/Board.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014-2015 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
src/Game/Goatee/Lib/Monad.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014-2015 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
src/Game/Goatee/Lib/Parser.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014-2015 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
src/Game/Goatee/Lib/Property.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
src/Game/Goatee/Lib/Property/Base.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014-2015 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
src/Game/Goatee/Lib/Property/Info.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
src/Game/Goatee/Lib/Property/Parser.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014-2015 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by@@ -54,6 +54,7 @@ #if !MIN_VERSION_base(4,8,0) import Data.Monoid (Monoid, mappend, mconcat, mempty) #endif+import Data.Semigroup as Sem ((<>), Semigroup) import qualified Game.Goatee.Common.Bigfloat as BF import Game.Goatee.Lib.Types import Text.ParserCombinators.Parsec (@@ -73,12 +74,15 @@ -- between two @CoordList@s. newtype CoordListMonoid = CoordListMonoid { runCoordListMonoid :: CoordList } +instance Sem.Semigroup CoordListMonoid where+ (<>) (CoordListMonoid x) (CoordListMonoid y) =+ CoordListMonoid $ coords' (coordListSingles x ++ coordListSingles y)+ (coordListRects x ++ coordListRects y)+ instance Monoid CoordListMonoid where mempty = CoordListMonoid emptyCoordList - mappend (CoordListMonoid x) (CoordListMonoid y) =- CoordListMonoid $ coords' (coordListSingles x ++ coordListSingles y)- (coordListRects x ++ coordListRects y)+ mappend = (<>) single :: Parser a -> Parser a single valueParser = char '[' *> valueParser <* char ']'
src/Game/Goatee/Lib/Property/Renderer.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
src/Game/Goatee/Lib/Property/Value.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
src/Game/Goatee/Lib/Renderer.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
src/Game/Goatee/Lib/Renderer/Tree.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
src/Game/Goatee/Lib/Tree.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014-2015 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
src/Game/Goatee/Lib/Types.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014-2015 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
tests/Game/Goatee/Common/BigfloatTest.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
tests/Game/Goatee/CommonTest.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014-2015 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by@@ -141,7 +141,7 @@ forTests = "for" ~: TestList [ "passes an empty list through" ~:- ([] @=?) =<< sequence (for [] $ const $ assertFailure "Nope.")+ ([] @=?) =<< sequence (for [] $ const $ (assertFailure "Nope." :: IO ())) , "operates on each element of a list" ~: [2, 2, 4, 6, 10] @=? for [1, 1, 2, 3, 5] (* 2)
tests/Game/Goatee/Lib/BoardTest.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014-2015 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
tests/Game/Goatee/Lib/MonadTest.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014-2015 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
tests/Game/Goatee/Lib/ParserTest.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
tests/Game/Goatee/Lib/ParserTestUtils.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014-2015 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
tests/Game/Goatee/Lib/Property/ParserTest.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014-2015 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
tests/Game/Goatee/Lib/PropertyTest.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
tests/Game/Goatee/Lib/RoundTripTest.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
tests/Game/Goatee/Lib/TestInstances.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
tests/Game/Goatee/Lib/TestUtils.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
tests/Game/Goatee/Lib/TreeTest.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
tests/Game/Goatee/Lib/TypesTest.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
tests/Game/Goatee/Test/Common.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by
tests/Test.hs view
@@ -1,6 +1,6 @@ -- This file is part of Goatee. ----- Copyright 2014 Bryan Gardiner+-- Copyright 2014-2018 Bryan Gardiner -- -- Goatee is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as published by