From 818385c842c137d106d3e9a2a0cbfaca21a97a95 Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Sat, 18 Jul 2015 18:25:33 -0500 Subject: [PATCH] update to build with GHC 7.10.1 and stack 0.1 --- .gitignore | 1 + src/Waterdeep/Actions.hs | 37 +++++++++++++++++++++++-------------- src/Waterdeep/Util.hs | 6 +----- stack.yaml | 6 ++++++ waterdeep.cabal | 12 ++++++------ 5 files changed, 37 insertions(+), 25 deletions(-) create mode 100644 stack.yaml diff --git a/.gitignore b/.gitignore index c434a52..6780ee4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *.hi *.o dist/ +.stack-work/ diff --git a/src/Waterdeep/Actions.hs b/src/Waterdeep/Actions.hs index c3047ed..1ece071 100644 --- a/src/Waterdeep/Actions.hs +++ b/src/Waterdeep/Actions.hs @@ -61,7 +61,7 @@ import Data.Maybe import Data.Monoid import Data.Foldable (foldMap, forM_, mapM_) import Data.Traversable (traverse, for, forM, mapM) -import Lens.Family2 +import Lens.Family2 hiding ((&)) import Lens.Family2.State import Lens.Family2.Stock import Prelude hiding (forM, mapM) @@ -307,10 +307,11 @@ returnAgent :: GameAction returnAgent = do w <- get let p = w^.gameActivePlayer - let buildings = flip foldMapBuildings w $ \_ bl -> - let agents = w^.bl.buildingAgents - title = w^.bl.building.buildingTitle - in mif (p `elem` agents) [(title, bl.buildingAgents %= (\\[p]))] + let buildings = foldMapBuildings f w + f :: Bool -> Lens' WaterdeepState BuildingState -> [(String, GameAction)] + f _ bl = mif (p `elem` agents) [(title, bl.buildingAgents %= (\\[p]))] + where agents = w^.bl.buildingAgents + title = w^.bl.building.buildingTitle join $ solicitChoice "Recall an agent from:" $ nubOn fst buildings activePlayerState . playerAgentsInPool += 1 @@ -368,7 +369,9 @@ assignAmbassador = do let includesOpponent = any (`elem` opponents) let usedOpSpace = (activePlayerState . playerCanUseOpSpace .= False) let canUseOpSpace = w ^. activePlayerState . playerCanUseOpSpace - let buildings = flip foldMapBuildings w $ \inHall bl -> + let buildings = foldMapBuildings f w + f :: Bool -> Lens' WaterdeepState BuildingState -> [(String, GameAction)] + f inHall bl = let agents = w^.bl.buildingAgents title = w^.bl.building.buildingTitle in if | canUseOpSpace && includesOpponent agents -> @@ -388,7 +391,9 @@ assignAgent = do let includesOpponent = any (`elem` opponents) let usedOpSpace = (activePlayerState . playerCanUseOpSpace .= False) let canUseOpSpace = w ^. activePlayerState . playerCanUseOpSpace - let buildings = flip foldMapBuildings w $ \inHall bl -> + let buildings = foldMapBuildings f w + f :: Bool -> Lens' WaterdeepState BuildingState -> [(String, GameAction)] + f inHall bl = let agents = w^.bl.buildingAgents title = w^.bl.building.buildingTitle in if | canUseOpSpace && includesOpponent agents -> @@ -408,7 +413,9 @@ assignAgentToBuildersHall = do let includesOpponent = any (`elem` opponents) let usedOpSpace = (activePlayerState . playerCanUseOpSpace .= False) let canUseOpSpace = w ^. activePlayerState . playerCanUseOpSpace - let buildings = flip foldMapBuildings w $ \inHall bl -> mif inHall $ + let buildings = foldMapBuildings f w + f :: Bool -> Lens' WaterdeepState BuildingState -> [(String, GameAction)] + f inHall bl = mif inHall $ let agents = w^.bl.buildingAgents title = w^.bl.building.buildingTitle in if null agents @@ -426,9 +433,10 @@ assignAgentToOpponentsSpace = do let p = w^.gameActivePlayer let opponents = (w^..gamePlayerStates.traverse.playerNumber) \\ [p] let includesOpponent = any (`elem` opponents) - let buildings = flip foldMapBuildings w $ \inHall bl -> - mif (includesOpponent (w^.bl.buildingAgents)) $ - [(w^.bl.building.buildingTitle, assignAgentToBuilding p bl)] + let buildings = foldMapBuildings f w + f :: Bool -> Lens' WaterdeepState BuildingState -> [(String, GameAction)] + f inHall bl = mif (includesOpponent (w^.bl.buildingAgents)) $ + [(w^.bl.building.buildingTitle, assignAgentToBuilding p bl)] join $ solicitChoice "Assign an agent to:" $ nubOn fst buildings useOpponentsSpace :: GameAction @@ -439,9 +447,10 @@ useOpponentsSpace = do let p = w^.gameActivePlayer let opponents = (w^..gamePlayerStates.traverse.playerNumber) \\ [p] let includesOpponent = any (`elem` opponents) - let buildings = flip foldMapBuildings w $ \inHall bl -> - mif (includesOpponent (w^.bl.buildingAgents)) $ - [(w^.bl.building.buildingTitle, useBuilding bl)] + let buildings = foldMapBuildings f w + f :: Bool -> Lens' WaterdeepState BuildingState -> [(String, GameAction)] + f inHall bl = mif (includesOpponent (w^.bl.buildingAgents)) $ + [(w^.bl.building.buildingTitle, useBuilding bl)] join $ solicitChoice "Use the effect of one building:" $ nubOn fst buildings gainLieutenant :: GameAction diff --git a/src/Waterdeep/Util.hs b/src/Waterdeep/Util.hs index a38e3e1..21be642 100644 --- a/src/Waterdeep/Util.hs +++ b/src/Waterdeep/Util.hs @@ -5,7 +5,6 @@ module Waterdeep.Util ( deleteAt , on , nubOn - , sortOn , countOf , singular , mif @@ -24,7 +23,7 @@ import Data.List import Data.Function import Data.Maybe import Data.Monoid -import Lens.Family2 +import Lens.Family2 hiding ((&)) import Lens.Family2.State import Lens.Family2.Stock @@ -37,9 +36,6 @@ deleteAt n l = left ++ drop 1 right nubOn :: Eq b => (a -> b) -> [a] -> [a] nubOn f = nubBy ((==) `on` f) -sortOn :: Ord b => (a -> b) -> [a] -> [a] -sortOn f = sortBy (compare `on` f) - countOf :: Num r => FoldLike (Sum r) a a' b b' -> (b -> Bool) -> a -> r countOf l f = getSum . views l (\b -> if f b then Sum 1 else Sum 0) diff --git a/stack.yaml b/stack.yaml new file mode 100644 index 0000000..96306a5 --- /dev/null +++ b/stack.yaml @@ -0,0 +1,6 @@ +flags: {} +packages: +- '.' +extra-deps: + - 'multiset-0.2.2' +resolver: nightly-2015-06-23 diff --git a/waterdeep.cabal b/waterdeep.cabal index a96f492..78dd283 100644 --- a/waterdeep.cabal +++ b/waterdeep.cabal @@ -25,16 +25,16 @@ executable waterdeep RankNTypes, TemplateHaskell, TupleSections - build-depends: base >=4.6 && <4.8, + build-depends: base >=4.6 && <4.9, MonadPrompt >=1.0 && <1.1, MonadRandom >=0.1 && <0.4, - containers >=0.5 && <0.6, + containers >=0.5.6.2 && <0.6, lens-family >=1.0 && <1.3, lens-family-th >=0.3 && <0.5, - mtl >=2.1 && <2.2, - multiset >=0.2 && <0.3, - random >=1.0 && <1.1, + mtl >=2.1 && <2.3, + multiset >= 0.2.2 && <0.3, + random >=1.0 && <1.2, random-shuffle >=0.0 && <0.1, - transformers >=0.3 && <0.4 + transformers >=0.3 && <0.5 hs-source-dirs: src default-language: Haskell2010