on master help sign in
lint free examples
354f761Harendra Kumar
examples/AcidRain.hs+1−1
@@ -33,7 +33,7 @@ game = do
33
33
34 h <- get
34 h <- get
35 when (h <= 0) $ fail "You die!"
35 when (h <= 0) $ fail "You die!"
36− liftIO $ putStrLn $ "Health = " ++ show h
36+ liftIO $ putStrLn $ "Health = " <> show h
37
37
38main :: IO ()
38main :: IO ()
39main = do
39main = do
examples/CirclingSquare.hs+2−3
@@ -55,8 +55,7 @@ updateController :: IORef (Double, Double) -> IO ()
55updateController ref = do
55updateController ref = do
56 e <- pollEvent
56 e <- pollEvent
57 case e of
57 case e of
58− MouseMotion x y _ _ -> do
59− writeIORef ref (fromIntegral x, fromIntegral y)
58+ MouseMotion x y _ _ -> writeIORef ref (fromIntegral x, fromIntegral y)
60 _ -> return ()
59 _ -> return ()
61
60
62------------------------------------------------------------------------------
61------------------------------------------------------------------------------
@@ -67,7 +66,7 @@ updateDisplay :: IORef (Double, Double) -> IO ()
67updateDisplay cref = do
66updateDisplay cref = do
68 time <- SDL.getTicks
67 time <- SDL.getTicks
69 (x, y) <- readIORef cref
68 (x, y) <- readIORef cref
70− let t = (fromIntegral time) * speed / 1000
69+ let t = fromIntegral time * speed / 1000
71 in display (x + cos t * radius, y + sin t * radius)
70 in display (x + cos t * radius, y + sin t * radius)
72
71
73 where
72 where
examples/ListDir.hs+2−2
@@ -1,7 +1,7 @@
1import Control.Monad.IO.Class (liftIO)
1import Control.Monad.IO.Class (liftIO)
2import Path.IO (listDir, getCurrentDir)
2import Path.IO (listDir, getCurrentDir)
3import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
3import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
4−import Streamly (runStream, aheadly)
4+import Streamly (runStream, aheadly, (<>))
5
5
6-- | List the current directory recursively using concurrent processing
6-- | List the current directory recursively using concurrent processing
7--
7--
@@ -14,5 +14,5 @@ main = do
14 runStream . aheadly $ getCurrentDir >>= readdir
14 runStream . aheadly $ getCurrentDir >>= readdir
15 where readdir d = do
15 where readdir d = do
16 (ds, fs) <- listDir d
16 (ds, fs) <- listDir d
17− liftIO $ mapM_ putStrLn $ map show fs ++ map show ds
17+ liftIO $ mapM_ putStrLn $ fmap show fs <> fmap show ds
18 foldMap readdir ds
18 foldMap readdir ds
examples/MergeSort.hs+4−4
@@ -30,11 +30,11 @@ merge a b = do
30 case b1 of
30 case b1 of
31 Nothing -> return x <> ma
31 Nothing -> return x <> ma
32 Just (y, mb) ->
32 Just (y, mb) ->
33− if (y < x)
33+ if y < x
34− then (return y) <> merge (return x <> ma) mb
34+ then return y <> merge (return x <> ma) mb
35− else (return x) <> merge ma (return y <> mb)
35+ else return x <> merge ma (return y <> mb)
36
36
37main :: IO ()
37main :: IO ()
38main = do
38main = do
39 xs <- A.toList $ mergeAsync getSorted getSorted
39 xs <- A.toList $ mergeAsync getSorted getSorted
40− putStrLn $ show $ length xs
40+ print $ length xs
examples/SearchQuery.hs+1−1
@@ -21,7 +21,7 @@ main = do
21
21
22 where
22 where
23 get :: String -> IO ()
23 get :: String -> IO ()
24− get s = httpNoBody (parseRequest_ s) >> putStrLn (show s)
24+ get s = httpNoBody (parseRequest_ s) >> print s
25
25
26 google, bing, duckduckgo :: IO ()
26 google, bing, duckduckgo :: IO ()
27 google = get "https://www.google.com/search?q=haskell"
27 google = get "https://www.google.com/search?q=haskell"