update to build with GHC 7.10.1 and stack 0.1

This commit is contained in:
Jesse D. McDonald 2015-07-18 18:25:33 -05:00
parent 647c07e4ca
commit 818385c842
5 changed files with 37 additions and 25 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
*.hi
*.o
dist/
.stack-work/

View File

@ -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

View File

@ -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)

6
stack.yaml Normal file
View File

@ -0,0 +1,6 @@
flags: {}
packages:
- '.'
extra-deps:
- 'multiset-0.2.2'
resolver: nightly-2015-06-23

View File

@ -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