on master help sign in
Use cycle1
commit0bde21205a1ed38f6282638782b1935115d001b1 authorHarendra Kumar <harendra.kumar@gmail.com> dateSun 10 Sep 2017, 15:20 (9 years ago) parentc870bbb
1 file changed+3−3
examples/game.hs+3−3
examples/game.hs+3−3
@@ -7,12 +7,12 @@ import Asyncly
77import Control.Concurrent (threadDelay)
88import Control.Monad (when)
99import Control.Monad.State
10−import Data.Foldable (fold)
10+import Data.Semigroup (cycle1)
1111
1212data Event = Harm Int | Heal Int | Quit deriving (Show)
1313
1414userAction :: MonadIO m => AsyncT m Event
15−userAction = fold $ repeat $ liftIO $ askUser
15+userAction = cycle1 $ liftIO askUser
1616 where
1717 askUser = do
1818 command <- getLine
@@ -22,7 +22,7 @@ userAction = fold $ repeat $ liftIO $ askUser
2222 _ -> putStrLn "What?" >> askUser
2323
2424acidRain :: MonadIO m => AsyncT m Event
25−acidRain = fold $ repeat $ liftIO (threadDelay 1000000) >> return (Harm 1)
25+acidRain = cycle1 $ liftIO (threadDelay 1000000) >> return (Harm 1)
2626
2727game :: (MonadAsync m, MonadState Int m) => AsyncT m ()
2828game = do