on master help sign in
lint free examples
commit354f7615fa876096756cd6b55d7b950172f564bf authorHarendra Kumar <harendra.kumar@gmail.com> dateSat 13 Oct 2018, 13:15 (8 years ago) parentbf81f70
5 files changed+10−11
examples/AcidRain.hs+1−1 examples/CirclingSquare.hs+2−3 examples/ListDir.hs+2−2 examples/MergeSort.hs+4−4 examples/SearchQuery.hs+1−1
examples/AcidRain.hs+1−1
@@ -33,7 +33,7 @@ game = do
3333
3434 h <- get
3535 when (h <= 0) $ fail "You die!"
36− liftIO $ putStrLn $ "Health = " ++ show h
36+ liftIO $ putStrLn $ "Health = " <> show h
3737
3838main :: IO ()
3939main = do
examples/CirclingSquare.hs+2−3
@@ -55,8 +55,7 @@ updateController :: IORef (Double, Double) -> IO ()
5555updateController ref = do
5656 e <- pollEvent
5757 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)
6059 _ -> return ()
6160
6261------------------------------------------------------------------------------
@@ -67,7 +66,7 @@ updateDisplay :: IORef (Double, Double) -> IO ()
6766updateDisplay cref = do
6867 time <- SDL.getTicks
6968 (x, y) <- readIORef cref
70− let t = (fromIntegral time) * speed / 1000
69+ let t = fromIntegral time * speed / 1000
7170 in display (x + cos t * radius, y + sin t * radius)
7271
7372 where
examples/ListDir.hs+2−2
@@ -1,7 +1,7 @@
11import Control.Monad.IO.Class (liftIO)
22import Path.IO (listDir, getCurrentDir)
33import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
4−import Streamly (runStream, aheadly)
4+import Streamly (runStream, aheadly, (<>))
55
66-- | List the current directory recursively using concurrent processing
77--
@@ -14,5 +14,5 @@ main = do
1414 runStream . aheadly $ getCurrentDir >>= readdir
1515 where readdir d = do
1616 (ds, fs) <- listDir d
17− liftIO $ mapM_ putStrLn $ map show fs ++ map show ds
17+ liftIO $ mapM_ putStrLn $ fmap show fs <> fmap show ds
1818 foldMap readdir ds
examples/MergeSort.hs+4−4
@@ -30,11 +30,11 @@ merge a b = do
3030 case b1 of
3131 Nothing -> return x <> ma
3232 Just (y, mb) ->
33− if (y < x)
34− then (return y) <> merge (return x <> ma) mb
35− else (return x) <> merge ma (return y <> mb)
33+ if y < x
34+ then return y <> merge (return x <> ma) mb
35+ else return x <> merge ma (return y <> mb)
3636
3737main :: IO ()
3838main = do
3939 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
2121
2222 where
2323 get :: String -> IO ()
24− get s = httpNoBody (parseRequest_ s) >> putStrLn (show s)
24+ get s = httpNoBody (parseRequest_ s) >> print s
2525
2626 google, bing, duckduckgo :: IO ()
2727 google = get "https://www.google.com/search?q=haskell"