on master help sign in
fix some hlint warnings
114ab1fHarendra Kumar
benchmark/Chart.hs+5−7
@@ -207,13 +207,11 @@ showStreamDVsK Options{..} cfg func inp out =
207 else ignoringErr $ report inp Nothing cfg'
207 else ignoringErr $ report inp Nothing cfg'
208
208
209 where
209 where
210+
210− classify b =
211+ classify b
211− if "streamD/" `isPrefixOf` b
212− then fmap ("streamD",) $ stripPrefix "streamD/" b
212+ | "streamD/" `isPrefixOf` b = ("streamD",) <$> stripPrefix "streamD/" b
213− else
214− if "streamK/" `isPrefixOf` b
215− then fmap ("streamK",) $ stripPrefix "streamK/" b
213+ | "streamK/" `isPrefixOf` b = ("streamK",) <$> stripPrefix "streamK/" b
216− else Nothing
214+ | otherwise = Nothing
217
215
218main :: IO ()
216main :: IO ()
219main = do
217main = do
benchmark/StreamDOps.hs+2−4
@@ -106,13 +106,11 @@ tail s = S.tail s >>= mapM_ tail
106
106
107nullTail s = do
107nullTail s = do
108 r <- S.null s
108 r <- S.null s
109− when (not r) $ do
110− S.tail s >>= mapM_ nullTail
109+ when (not r) $ S.tail s >>= mapM_ nullTail
111
110
112headTail s = do
111headTail s = do
113 h <- S.head s
112 h <- S.head s
114− when (isJust h) $
115− S.tail s >>= mapM_ headTail
113+ when (isJust h) $ S.tail s >>= mapM_ headTail
116
114
117toList = S.toList
115toList = S.toList
118foldl = S.foldl' (+) 0
116foldl = S.foldl' (+) 0
benchmark/StreamKOps.hs+2−4
@@ -124,13 +124,11 @@ tail s = S.tail s >>= mapM_ tail
124
124
125nullTail s = do
125nullTail s = do
126 r <- S.null s
126 r <- S.null s
127− when (not r) $ do
128− S.tail s >>= mapM_ nullTail
127+ when (not r) $ S.tail s >>= mapM_ nullTail
129
128
130headTail s = do
129headTail s = do
131 h <- S.head s
130 h <- S.head s
132− when (isJust h) $
133− S.tail s >>= mapM_ headTail
131+ when (isJust h) $ S.tail s >>= mapM_ headTail
134
132
135toList = S.toList
133toList = S.toList
136foldl = S.foldl' (+) 0
134foldl = S.foldl' (+) 0
examples/ControlFlow.hs+28−28
@@ -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: "
49
49
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
52
52
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: "
79
79
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
82
82
83 r1 <- liftIO getLine
83 r1 <- liftIO getLine
84− when (r1 /= "x") $ mzero
84+ when (r1 /= "x") mzero
85
85
86 r2 <- liftIO getLine
86 r2 <- liftIO getLine
87− when (r2 /= "y") $ mzero
87+ when (r2 /= "y") mzero
88
88
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: "
112
112
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
115
115
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
118
118
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
121
121
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)
144 )
144 )
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
155
155
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: "
179
179
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
182
182
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
185
185
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
188
188
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)
194
194
195-------------------------------------------------------------------------------
195-------------------------------------------------------------------------------
196-- Using MonadThrow to throw exceptions in streamly
196-- Using MonadThrow to throw exceptions in streamly
197-------------------------------------------------------------------------------
197-------------------------------------------------------------------------------
198--
198--
199−data Unexpected = Unexpected String deriving Show
199+newtype Unexpected = Unexpected String deriving Show
200
200
201instance Exception Unexpected
201instance Exception Unexpected
202
202
@@ -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: "
210
210
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
213
213
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
216
216
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
219
219
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)
224
224
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: "
239
239
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
242
242
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 ()
248
248
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
254 return r
254 return r
255
255
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: "
273
273
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
276
276
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 ()
282
282
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 ()
287
287
288mainContAbove :: (IsStream t, Monad m, MonadIO (t m)) => ContT r (t m) ()
288mainContAbove :: (IsStream t, Monad m, MonadIO (t m)) => ContT r (t m) ()