{-# LANGUAGE LambdaCase #-}
module Yahtzee (DiceChoice (..), DiceVals, allRolls) where
type DiceVals = [Word]
data DiceChoice = Keep Word | Reroll
allRolls :: [DiceChoice] -> [DiceVals]
allRolls :: [DiceChoice] -> [DiceVals]
allRolls = (DiceChoice -> DiceVals) -> [DiceChoice] -> [DiceVals]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((DiceChoice -> DiceVals) -> [DiceChoice] -> [DiceVals])
-> (DiceChoice -> DiceVals) -> [DiceChoice] -> [DiceVals]
forall a b. (a -> b) -> a -> b
$ \case
DiceChoice
Reroll -> [Word
1..Word
6]
Keep Word
v -> [Word
v]