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 *.hi
*.o *.o
dist/ dist/
.stack-work/

View File

@ -61,7 +61,7 @@ import Data.Maybe
import Data.Monoid import Data.Monoid
import Data.Foldable (foldMap, forM_, mapM_) import Data.Foldable (foldMap, forM_, mapM_)
import Data.Traversable (traverse, for, forM, mapM) import Data.Traversable (traverse, for, forM, mapM)
import Lens.Family2 import Lens.Family2 hiding ((&))
import Lens.Family2.State import Lens.Family2.State
import Lens.Family2.Stock import Lens.Family2.Stock
import Prelude hiding (forM, mapM) import Prelude hiding (forM, mapM)
@ -307,10 +307,11 @@ returnAgent :: GameAction
returnAgent = do returnAgent = do
w <- get w <- get
let p = w^.gameActivePlayer let p = w^.gameActivePlayer
let buildings = flip foldMapBuildings w $ \_ bl -> let buildings = foldMapBuildings f w
let agents = w^.bl.buildingAgents 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 title = w^.bl.building.buildingTitle
in mif (p `elem` agents) [(title, bl.buildingAgents %= (\\[p]))]
join $ solicitChoice "Recall an agent from:" $ nubOn fst buildings join $ solicitChoice "Recall an agent from:" $ nubOn fst buildings
activePlayerState . playerAgentsInPool += 1 activePlayerState . playerAgentsInPool += 1
@ -368,7 +369,9 @@ assignAmbassador = do
let includesOpponent = any (`elem` opponents) let includesOpponent = any (`elem` opponents)
let usedOpSpace = (activePlayerState . playerCanUseOpSpace .= False) let usedOpSpace = (activePlayerState . playerCanUseOpSpace .= False)
let canUseOpSpace = w ^. activePlayerState . playerCanUseOpSpace 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 let agents = w^.bl.buildingAgents
title = w^.bl.building.buildingTitle title = w^.bl.building.buildingTitle
in if | canUseOpSpace && includesOpponent agents -> in if | canUseOpSpace && includesOpponent agents ->
@ -388,7 +391,9 @@ assignAgent = do
let includesOpponent = any (`elem` opponents) let includesOpponent = any (`elem` opponents)
let usedOpSpace = (activePlayerState . playerCanUseOpSpace .= False) let usedOpSpace = (activePlayerState . playerCanUseOpSpace .= False)
let canUseOpSpace = w ^. activePlayerState . playerCanUseOpSpace 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 let agents = w^.bl.buildingAgents
title = w^.bl.building.buildingTitle title = w^.bl.building.buildingTitle
in if | canUseOpSpace && includesOpponent agents -> in if | canUseOpSpace && includesOpponent agents ->
@ -408,7 +413,9 @@ assignAgentToBuildersHall = do
let includesOpponent = any (`elem` opponents) let includesOpponent = any (`elem` opponents)
let usedOpSpace = (activePlayerState . playerCanUseOpSpace .= False) let usedOpSpace = (activePlayerState . playerCanUseOpSpace .= False)
let canUseOpSpace = w ^. activePlayerState . playerCanUseOpSpace 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 let agents = w^.bl.buildingAgents
title = w^.bl.building.buildingTitle title = w^.bl.building.buildingTitle
in if null agents in if null agents
@ -426,8 +433,9 @@ assignAgentToOpponentsSpace = do
let p = w^.gameActivePlayer let p = w^.gameActivePlayer
let opponents = (w^..gamePlayerStates.traverse.playerNumber) \\ [p] let opponents = (w^..gamePlayerStates.traverse.playerNumber) \\ [p]
let includesOpponent = any (`elem` opponents) let includesOpponent = any (`elem` opponents)
let buildings = flip foldMapBuildings w $ \inHall bl -> let buildings = foldMapBuildings f w
mif (includesOpponent (w^.bl.buildingAgents)) $ f :: Bool -> Lens' WaterdeepState BuildingState -> [(String, GameAction)]
f inHall bl = mif (includesOpponent (w^.bl.buildingAgents)) $
[(w^.bl.building.buildingTitle, assignAgentToBuilding p bl)] [(w^.bl.building.buildingTitle, assignAgentToBuilding p bl)]
join $ solicitChoice "Assign an agent to:" $ nubOn fst buildings join $ solicitChoice "Assign an agent to:" $ nubOn fst buildings
@ -439,8 +447,9 @@ useOpponentsSpace = do
let p = w^.gameActivePlayer let p = w^.gameActivePlayer
let opponents = (w^..gamePlayerStates.traverse.playerNumber) \\ [p] let opponents = (w^..gamePlayerStates.traverse.playerNumber) \\ [p]
let includesOpponent = any (`elem` opponents) let includesOpponent = any (`elem` opponents)
let buildings = flip foldMapBuildings w $ \inHall bl -> let buildings = foldMapBuildings f w
mif (includesOpponent (w^.bl.buildingAgents)) $ f :: Bool -> Lens' WaterdeepState BuildingState -> [(String, GameAction)]
f inHall bl = mif (includesOpponent (w^.bl.buildingAgents)) $
[(w^.bl.building.buildingTitle, useBuilding bl)] [(w^.bl.building.buildingTitle, useBuilding bl)]
join $ solicitChoice "Use the effect of one building:" $ nubOn fst buildings join $ solicitChoice "Use the effect of one building:" $ nubOn fst buildings

View File

@ -5,7 +5,6 @@ module Waterdeep.Util
( deleteAt ( deleteAt
, on , on
, nubOn , nubOn
, sortOn
, countOf , countOf
, singular , singular
, mif , mif
@ -24,7 +23,7 @@ import Data.List
import Data.Function import Data.Function
import Data.Maybe import Data.Maybe
import Data.Monoid import Data.Monoid
import Lens.Family2 import Lens.Family2 hiding ((&))
import Lens.Family2.State import Lens.Family2.State
import Lens.Family2.Stock import Lens.Family2.Stock
@ -37,9 +36,6 @@ deleteAt n l = left ++ drop 1 right
nubOn :: Eq b => (a -> b) -> [a] -> [a] nubOn :: Eq b => (a -> b) -> [a] -> [a]
nubOn f = nubBy ((==) `on` f) 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 :: 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) 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, RankNTypes,
TemplateHaskell, TemplateHaskell,
TupleSections TupleSections
build-depends: base >=4.6 && <4.8, build-depends: base >=4.6 && <4.9,
MonadPrompt >=1.0 && <1.1, MonadPrompt >=1.0 && <1.1,
MonadRandom >=0.1 && <0.4, 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 >=1.0 && <1.3,
lens-family-th >=0.3 && <0.5, lens-family-th >=0.3 && <0.5,
mtl >=2.1 && <2.2, mtl >=2.1 && <2.3,
multiset >=0.2 && <0.3, multiset >= 0.2.2 && <0.3,
random >=1.0 && <1.1, random >=1.0 && <1.2,
random-shuffle >=0.0 && <0.1, random-shuffle >=0.0 && <0.1,
transformers >=0.3 && <0.4 transformers >=0.3 && <0.5
hs-source-dirs: src hs-source-dirs: src
default-language: Haskell2010 default-language: Haskell2010