Skip to content

Commit

Permalink
Add flush of stdout.
Browse files Browse the repository at this point in the history
  • Loading branch information
FranklinChen committed Feb 17, 2015
1 parent 99e3023 commit 51fa56e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions examples/haskell/count.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import Control.Monad (forM_)
import Control.Concurrent (threadDelay)
import System.IO (hFlush, stdout)

-- | Count from 1 to 10 with a sleep
main :: IO ()
main = forM_ [1 :: Int .. 10] $ \count -> do
print count
hFlush stdout
threadDelay 500000
3 changes: 2 additions & 1 deletion examples/haskell/greeter.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env runhaskell

import Control.Monad (unless)
import System.IO (stdin, hIsEOF)
import System.IO (hFlush, stdout, stdin, hIsEOF)

-- | For each line FOO received on STDIN, respond with "Hello FOO!".
main :: IO ()
Expand All @@ -10,4 +10,5 @@ main = do
unless eof $ do
line <- getLine
putStrLn $ "Hello " ++ line ++ "!"
hFlush stdout
main

0 comments on commit 51fa56e

Please sign in to comment.