Applicative functions
This commit is contained in:
parent
349022a7cc
commit
80e71eb859
1 changed files with 6 additions and 5 deletions
|
@ -13,6 +13,7 @@ import Lens.Micro.TH
|
||||||
import System.Random (getStdRandom, randomR)
|
import System.Random (getStdRandom, randomR)
|
||||||
|
|
||||||
import Prelude hiding (Left, Right)
|
import Prelude hiding (Left, Right)
|
||||||
|
import Data.Bool (bool)
|
||||||
import Data.Maybe (fromMaybe)
|
import Data.Maybe (fromMaybe)
|
||||||
import Data.Monoid (First(..))
|
import Data.Monoid (First(..))
|
||||||
|
|
||||||
|
@ -161,11 +162,11 @@ isGameOver :: Game -> Bool
|
||||||
isGameOver g = blockStopped g && g ^. block ^. origin == startOrigin
|
isGameOver g = blockStopped g && g ^. block ^. origin == startOrigin
|
||||||
|
|
||||||
timeStep :: Game -> IO Game
|
timeStep :: Game -> IO Game
|
||||||
timeStep g = if (blockStopped g)
|
timeStep =
|
||||||
then stopUpdater g
|
bool
|
||||||
else return . gravitate $ g
|
<$> (return . gravitate) -- if not stopped
|
||||||
where
|
<*> nextBlock . updateScore . clearFullRows . freezeBlock -- if stopped
|
||||||
stopUpdater = nextBlock . updateScore . clearFullRows . freezeBlock
|
<*> blockStopped -- predicate
|
||||||
|
|
||||||
-- TODO check if mapKeysMonotonic works
|
-- TODO check if mapKeysMonotonic works
|
||||||
clearFullRows :: Game -> Game
|
clearFullRows :: Game -> Game
|
||||||
|
|
Loading…
Add table
Reference in a new issue