Async logging in the repl

Hi there, another newbie question :sweat_smile:

According to the purescript book:

Note that asynchronous logging in the repl just waits to print until the entire block has finished executing. This code behaves more predictably when run with spago test where there is a slight delay between prints.

link

I don’t really understand the design decision to make the repl wait to print all. For a newbie like me makes it difficult to debug purescript async code in the repl.

I know that, once built, this little program:

sleep3s :: Aff Unit
sleep3s = delay $ Milliseconds 3000.0

program :: Effect Unit
program = launchAff_ do
  log "waiting"
  sleep3s
  log "done waiting"

Behaves as it should. Therefore, how can I reproduce the same behaviour in the repl?

My understanding is that this wasn’t so much an intentional decision, but rather a current limitation. There are some plans to improve the repl’s Aff handling, discussed in Collaborating on improving the REPL evaluator

1 Like

I see. I guess that I can still check async functions with the spago run command and the --main flag, so luckily it’s not so much of an issue while developing.

Thanks for answering! :smiley: