Replace list by triple in deal function following error on failable pattern with GHC 8.6.3

This commit is contained in:
Tissevert 2019-01-13 13:16:29 +01:00
parent 18d544e13f
commit 14d58d002e

View file

@ -10,11 +10,11 @@ import Hanafuda.KoiKoi.Game (Game, Mode(..), On(..), Step(..), end, stop)
import qualified Hanafuda.Player as Player (deal, get, next, score) import qualified Hanafuda.Player as Player (deal, get, next, score)
import Data.Map ((!), insert) import Data.Map ((!), insert)
import Control.Monad.IO.Class (MonadIO) import Control.Monad.IO.Class (MonadIO)
import Control.Monad.State (replicateM, runState, state) import Control.Monad.State (runState, state)
deal :: (MonadIO m, Ord player) => On player -> m (On player) deal :: (MonadIO m, Ord player) => On player -> m (On player)
deal on@(On_ {players}) = do deal on@(On_ {players}) = do
([hand1, hand2, river], deck) <- fmap (runState (replicateM 3 take8)) $ shuffle cards ((hand1, hand2, river), deck) <- runState getTriple <$> shuffle cards
return on { return on {
players = Player.deal players [hand1, hand2] players = Player.deal players [hand1, hand2]
, deck , deck
@ -22,6 +22,7 @@ deal on@(On_ {players}) = do
} }
where where
take8 = state $ splitAt 8 take8 = state $ splitAt 8
getTriple = (,,) <$> take8 <*> take8 <*> take8
next :: (MonadIO m, Ord player) => On player -> m (Game player) next :: (MonadIO m, Ord player) => On player -> m (Game player)
next on@(On_ {mode, scores, month, players, oyake, winning}) = next on@(On_ {mode, scores, month, players, oyake, winning}) =