Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Say not printing concurrently on Windows #4

Open
TimeTravelPenguin opened this issue Sep 13, 2022 · 0 comments
Open

Say not printing concurrently on Windows #4

TimeTravelPenguin opened this issue Sep 13, 2022 · 0 comments

Comments

@TimeTravelPenguin
Copy link

Following through this tutorial, found here on YouTube, the following code does not run on my Windows machine:

{-# LANGUAGE OverloadedStrings #-}

module Main (main) where

import Control.Concurrent (threadDelay)
import Control.Concurrent.Async
import Data.Foldable (for_)
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Text.IO as TIO
import Say

getUrlWithDelay :: Integer -> Text -> IO Text
getUrlWithDelay delay url = do
  say $ "Downloading: " <> url
  forM_ [1 .. delay] $ \s -> do
    threadDelay (1 * 1000000)
    say $ "Downloading: " <> url <> " -- " <> T.pack (show s) <> " seconds"
  return $ "Contents: " <> URL
  
main :: IO ()
main = do
  say "Starting"

  (res1, res2, res3) <-
    runConcurrently $
      (,,)
        <$> Concurrently (getUrlWithDelay 2 "first")
        <*> Concurrently (getUrlWithDelay 4 "second")
        <*> Concurrently (getUrlWithDelay 3 "third")

  print res1
  print res2
  print res3

Specifically, in the function getUrlWithDelay, the use of say does not print to my console concurrently. Instead, it all shows at the end of all concurrently run functions.

I am compiling with stack with the default options for a new project, so I am certain that is not the issue. Furthermore, it runs as expected when compiling and using stack run on my Ubuntu subsystem (via WSL).

@TimeTravelPenguin TimeTravelPenguin changed the title Not working on Windows Say not printing concurrently on Windows Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant