on master help sign in
remove the Quit constructor
commit0ef728a55ff8ed926e94613e3585c4d7bd17f403 authorHarendra Kumar <harendra.kumar@gmail.com> dateWed 19 Sep 2018, 23:18 (8 years ago) parent49542d2
1 file changed+3−4
examples/AcidRain.hs+3−4
examples/AcidRain.hs+3−4
@@ -7,9 +7,9 @@ import Streamly
77import Streamly.Prelude as S
88import Control.Monad (when)
99import Control.Monad.IO.Class (MonadIO(liftIO))
10−import Control.Monad.State (MonadState, get, modify, runStateT)
10+import Control.Monad.State (MonadState, get, modify, runStateT, put)
1111
12−data Event = Harm Int | Heal Int | Quit deriving (Show)
12+data Event = Harm Int | Heal Int deriving (Show)
1313
1414userAction :: MonadAsync m => SerialT m Event
1515userAction = S.repeatM $ liftIO askUser
@@ -18,7 +18,7 @@ userAction = S.repeatM $ liftIO askUser
1818 command <- getLine
1919 case command of
2020 "potion" -> return (Heal 10)
21− "quit" -> return Quit
21+ "quit" -> fail "quit"
2222 _ -> putStrLn "What?" >> askUser
2323
2424acidRain :: MonadAsync m => SerialT m Event
@@ -30,7 +30,6 @@ game = do
3030 case event of
3131 Harm n -> modify $ \h -> h - n
3232 Heal n -> modify $ \h -> h + n
33− Quit -> fail "quit"
3433
3534 h <- get
3635 when (h <= 0) $ fail "You die!"