@@ -48,7 +48,7 @@ getSequenceMaybeBelow = do
48 liftIO $ putStrLn "MaybeT below streamly: Enter one char per line: "
48 liftIO $ putStrLn "MaybeT below streamly: Enter one char per line: "
50 i <- S.fromFoldable [1..2 :: Int]
50 i <- S.fromFoldable [1..2 :: Int]
51− liftIO $ putStrLn $ "iteration = " ++ show i
51+ liftIO $ putStrLn $ "iteration = " <> show i
53 r1 <- liftIO getLine
53 r1 <- liftIO getLine
54 when (r1 /= "x") $ lift mzero
54 when (r1 /= "x") $ lift mzero
@@ -78,13 +78,13 @@ getSequenceMaybeAbove = do
78 liftIO $ putStrLn "MaybeT above streamly: Enter one char per line: "
78 liftIO $ putStrLn "MaybeT above streamly: Enter one char per line: "
80 i <- lift $ S.fromFoldable [1..2 :: Int]
80 i <- lift $ S.fromFoldable [1..2 :: Int]
81− liftIO $ putStrLn $ "iteration = " ++ show i
81+ liftIO $ putStrLn $ "iteration = " <> show i
83 r1 <- liftIO getLine
83 r1 <- liftIO getLine
84− when (r1 /= "x") $ mzero
84+ when (r1 /= "x") mzero
86 r2 <- liftIO getLine
86 r2 <- liftIO getLine
87− when (r2 /= "y") $ mzero
87+ when (r2 /= "y") mzero
89mainMaybeAbove :: (IsStream t, MonadIO (t m)) => MaybeT (t m) ()
89mainMaybeAbove :: (IsStream t, MonadIO (t m)) => MaybeT (t m) ()
90mainMaybeAbove = do
90mainMaybeAbove = do
@@ -111,13 +111,13 @@ getSequenceEitherBelow = do
111 liftIO $ putStrLn "ExceptT below streamly: Enter one char per line: "
111 liftIO $ putStrLn "ExceptT below streamly: Enter one char per line: "
113 i <- S.fromFoldable [1..2 :: Int]
113 i <- S.fromFoldable [1..2 :: Int]
114− liftIO $ putStrLn $ "iteration = " ++ show i
114+ liftIO $ putStrLn $ "iteration = " <> show i
116 r1 <- liftIO getLine
116 r1 <- liftIO getLine
117− when (r1 /= "x") $ lift $ throwE $ "Expecting x got: " ++ r1
117+ when (r1 /= "x") $ lift $ throwE $ "Expecting x got: " <> r1
119 r2 <- liftIO getLine
119 r2 <- liftIO getLine
120− when (r2 /= "y") $ lift $ throwE $ "Expecting y got: " ++ r2
120+ when (r2 /= "y") $ lift $ throwE $ "Expecting y got: " <> r2
122mainEitherBelow :: IO ()
122mainEitherBelow :: IO ()
123mainEitherBelow = do
123mainEitherBelow = do
@@ -140,7 +140,7 @@ getSequenceEitherAsyncBelow
140 , MonadAsync m
140 , MonadAsync m
141 , MonadIO (t m)
141 , MonadIO (t m)
142 , MonadIO (t (ExceptT String m))
142 , MonadIO (t (ExceptT String m))
143− , Semigroup (t (ExceptT [Char] m) Integer)
143+ , Semigroup (t (ExceptT String m) Integer)
145 => t (ExceptT String m) ()
145 => t (ExceptT String m) ()
146getSequenceEitherAsyncBelow = do
146getSequenceEitherAsyncBelow = do
@@ -151,11 +151,11 @@ getSequenceEitherAsyncBelow = do
151 >> return 1)
151 >> return 1)
152 <> (lift (throwE "Second task") >> return 2)
152 <> (lift (throwE "Second task") >> return 2)
153 <> S.yield (3 :: Integer)
153 <> S.yield (3 :: Integer)
154− liftIO $ putStrLn $ "iteration = " ++ show i
154+ liftIO $ putStrLn $ "iteration = " <> show i
156mainEitherAsyncBelow :: IO ()
156mainEitherAsyncBelow :: IO ()
157mainEitherAsyncBelow = do
157mainEitherAsyncBelow = do
158− r <- runExceptT (runStream $ asyncly $ getSequenceEitherAsyncBelow)
158+ r <- runExceptT (runStream $ asyncly getSequenceEitherAsyncBelow)
159 case r of
159 case r of
160 Right _ -> liftIO $ putStrLn "Bingo"
160 Right _ -> liftIO $ putStrLn "Bingo"
161 Left s -> liftIO $ putStrLn s
161 Left s -> liftIO $ putStrLn s
@@ -178,25 +178,25 @@ getSequenceEitherAbove = do
178 liftIO $ putStrLn "ExceptT above streamly: Enter one char per line: "
178 liftIO $ putStrLn "ExceptT above streamly: Enter one char per line: "
180 i <- lift $ S.fromFoldable [1..2 :: Int]
180 i <- lift $ S.fromFoldable [1..2 :: Int]
181− liftIO $ putStrLn $ "iteration = " ++ show i
181+ liftIO $ putStrLn $ "iteration = " <> show i
183 r1 <- liftIO getLine
183 r1 <- liftIO getLine
184− when (r1 /= "x") $ throwE $ "Expecting x got: " ++ r1
184+ when (r1 /= "x") $ throwE $ "Expecting x got: " <> r1
186 r2 <- liftIO getLine
186 r2 <- liftIO getLine
187− when (r2 /= "y") $ throwE $ "Expecting y got: " ++ r2
187+ when (r2 /= "y") $ throwE $ "Expecting y got: " <> r2
189mainEitherAbove :: (IsStream t, Monad m, MonadIO (t m))
189mainEitherAbove :: (IsStream t, Monad m, MonadIO (t m))
190 => ExceptT String (t m) ()
190 => ExceptT String (t m) ()
191−mainEitherAbove = do
191+mainEitherAbove =
192 catchE (getSequenceEitherAbove >> liftIO (putStrLn "Bingo"))
192 catchE (getSequenceEitherAbove >> liftIO (putStrLn "Bingo"))
193− (\e -> liftIO $ putStrLn e)
193+ (liftIO . putStrLn)
195-------------------------------------------------------------------------------
195-------------------------------------------------------------------------------
196-- Using MonadThrow to throw exceptions in streamly
196-- Using MonadThrow to throw exceptions in streamly
197-------------------------------------------------------------------------------
197-------------------------------------------------------------------------------
199−data Unexpected = Unexpected String deriving Show
199+newtype Unexpected = Unexpected String deriving Show
201instance Exception Unexpected
201instance Exception Unexpected
@@ -209,18 +209,18 @@ getSequenceMonadThrow = do
209 liftIO $ putStrLn "MonadThrow in streamly: Enter one char per line: "
209 liftIO $ putStrLn "MonadThrow in streamly: Enter one char per line: "
211 i <- S.fromFoldable [1..2 :: Int]
211 i <- S.fromFoldable [1..2 :: Int]
212− liftIO $ putStrLn $ "iteration = " ++ show i
212+ liftIO $ putStrLn $ "iteration = " <> show i
214 r1 <- liftIO getLine
214 r1 <- liftIO getLine
215− when (r1 /= "x") $ throwM $ Unexpected $ "Expecting x got: " ++ r1
215+ when (r1 /= "x") $ throwM $ Unexpected $ "Expecting x got: " <> r1
217 r2 <- liftIO getLine
217 r2 <- liftIO getLine
218− when (r2 /= "y") $ throwM $ Unexpected $ "Expecting y got: " ++ r2
218+ when (r2 /= "y") $ throwM $ Unexpected $ "Expecting y got: " <> r2
220mainMonadThrow :: IO ()
220mainMonadThrow :: IO ()
221−mainMonadThrow = do
221+mainMonadThrow =
222 catch (runStream getSequenceMonadThrow >> liftIO (putStrLn "Bingo"))
222 catch (runStream getSequenceMonadThrow >> liftIO (putStrLn "Bingo"))
223− (\(e :: SomeException) -> liftIO $ putStrLn $ show e)
223+ (\(e :: SomeException) -> liftIO $ print e)
225-------------------------------------------------------------------------------
225-------------------------------------------------------------------------------
226-- Using ContT below streamly
226-- Using ContT below streamly
@@ -238,19 +238,19 @@ getSequenceContBelow = do
238 liftIO $ putStrLn "ContT below streamly: Enter one char per line: "
238 liftIO $ putStrLn "ContT below streamly: Enter one char per line: "
240 i <- S.fromFoldable [1..2 :: Int]
240 i <- S.fromFoldable [1..2 :: Int]
241− liftIO $ putStrLn $ "iteration = " ++ show i
241+ liftIO $ putStrLn $ "iteration = " <> show i
243 r <- lift $ callCC $ \exit -> do
243 r <- lift $ callCC $ \exit -> do
244 r1 <- liftIO getLine
244 r1 <- liftIO getLine
245 _ <- if r1 /= "x"
245 _ <- if r1 /= "x"
246− then exit $ Left $ "Expecting x got: " ++ r1
246+ then exit $ Left $ "Expecting x got: " <> r1
247 else return $ Right ()
247 else return $ Right ()
249 r2 <- liftIO getLine
249 r2 <- liftIO getLine
250 if r2 /= "y"
250 if r2 /= "y"
251− then exit $ Left $ "Expecting y got: " ++ r2
251+ then exit $ Left $ "Expecting y got: " <> r2
252 else return $ Right ()
252 else return $ Right ()
253− liftIO $ putStrLn $ "done iteration = " ++ show i
253+ liftIO $ putStrLn $ "done iteration = " <> show i
256mainContBelow
256mainContBelow
@@ -272,17 +272,17 @@ getSequenceContAbove = do
272 liftIO $ putStrLn "ContT above streamly: Enter one char per line: "
272 liftIO $ putStrLn "ContT above streamly: Enter one char per line: "
274 i <- lift $ S.fromFoldable [1..2 :: Int]
274 i <- lift $ S.fromFoldable [1..2 :: Int]
275− liftIO $ putStrLn $ "iteration = " ++ show i
275+ liftIO $ putStrLn $ "iteration = " <> show i
277 callCC $ \exit -> do
277 callCC $ \exit -> do
278 r1 <- liftIO getLine
278 r1 <- liftIO getLine
279 _ <- if r1 /= "x"
279 _ <- if r1 /= "x"
280− then exit $ Left $ "Expecting x got: " ++ r1
280+ then exit $ Left $ "Expecting x got: " <> r1
281 else return $ Right ()
281 else return $ Right ()
283 r2 <- liftIO getLine
283 r2 <- liftIO getLine
284 if r2 /= "y"
284 if r2 /= "y"
285− then exit $ Left $ "Expecting y got: " ++ r2
285+ then exit $ Left $ "Expecting y got: " <> r2
286 else return $ Right ()
286 else return $ Right ()
288mainContAbove :: (IsStream t, Monad m, MonadIO (t m)) => ContT r (t m) ()
288mainContAbove :: (IsStream t, Monad m, MonadIO (t m)) => ContT r (t m) ()