tweag/asterius

putStr is too lazy

Closed this issue · 0 comments

Describe the bug
Function putStr does not behave the same way in Asterius and GHC. For example:

main :: IO ()
main = putStr "a"
-- ghc-custom-asterius-8.8.3
--   a
-- ahc-link:
--       -- nothing here

as opposed to

main :: IO ()
main = putStrLn "a"
-- ghc-custom-asterius-8.8.3:
--   a
-- ahc-link
--   a

Though I thought that maybe putStr is a no-op, this is also not the case. It seems that it works just fine, if another command forces flushing the outputs:

main :: IO ()
main = putStr "a" >> putStrLn "b" >> putStr "c"
-- ghc-custom-asterius-8.8.3
--   ab
--   c
-- ahc-link:
--   ab  -- a is printed!
--       -- nothing here

To Reproduce
Put any of the above snippets in Main.hs, build it with Asterius, and execute using node:

ahc-link --input-hs Main.hs
node Main.mjs

Expected behavior
For all three main functions above, Asterius should give the same output as GHC does.

Environment

  • OS name + version: Ubuntu 18.04.4 LTS (bionic)
  • GHC version: 8.8.3
  • Cabal version: 3.2.0.0
  • Version of Asterius: 20b340f

Additional context
This showed up while developing #640. It seems to be affecting at least three tests (real/symalg, spectral/cichelli, and spectral/primetest).