Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. module Main where
  2.  
  3. import System.IO
  4.  
  5. {-
  6. main :: IO ()
  7. -- Idealy i would like to make the main function non blocking
  8. main = do
  9. s <- getContents
  10. putStrLn s -- main is blocking here because putStrLn is handling an infinite list
  11. putStrLn "Please print me" -- how to execute this while line above is waiting for input
  12. -}
  13.  
  14. -- this way
  15.  
  16. import Control.Concurrent
  17.  
  18. main :: IO ()
  19.  
  20. main = do
  21. forkIO $ do putStrLn "Please print me"
  22. s <- getContents
  23. putStrLn s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement