Idiomatic.hs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-- Number 1
takeTurn :: PlayerNumber -> GameState -> IO GameState
takeTurn p g = do
  print $ publicState g
  print $ handFor p g
  card <- chooseCard p g
  flag <- chooseFlag g
  return $ updateGame p card flag g

-- Number 2
takeTurn :: PlayerNumber -> GameState -> IO GameState
takeTurn p g = do
  print $ publicState g
  print $ handFor p g
  updateGame p <$> chooseCard p g <*> chooseFlag g <*> pure g