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

putStrLn doesn't work correctly with LineBuffering #242

Closed
domenkozar opened this issue Nov 25, 2018 · 1 comment · Fixed by #600
Closed

putStrLn doesn't work correctly with LineBuffering #242

domenkozar opened this issue Nov 25, 2018 · 1 comment · Fixed by #600

Comments

@domenkozar
Copy link

domenkozar commented Nov 25, 2018

Which can result into

pushing /nix/store/j2yzfcd4wli8lj5i6yvyg6h1sbvjr55i-glibc-2.27
pushing /nix/store/7jgadbmbxp4fz4c96qm154g8sq0y8398-ghc-8.4.3-docpushing /nix/store/vf475f9cg41h8dxz5g8i0mxvbbqpry36-attr-2.4.47

pushing /nix/store/fcyxw5aslw3a82p33x5lhckj0mr6g1s4-bash-4.4-p23

instead of

pushing /nix/store/j2yzfcd4wli8lj5i6yvyg6h1sbvjr55i-glibc-2.27
pushing /nix/store/7jgadbmbxp4fz4c96qm154g8sq0y8398-ghc-8.4.3-doc
pushing /nix/store/vf475f9cg41h8dxz5g8i0mxvbbqpry36-attr-2.4.47
pushing /nix/store/fcyxw5aslw3a82p33x5lhckj0mr6g1s4-bash-4.4-p23

It's currently implemented as:

hPutStrLn :: Handle -> Text -> IO ()
hPutStrLn h t = hPutStr h t >> hPutChar h '\n'

The naive approach is to append the newline at the end of t.

GHC's hPutStrLn handles newline as special optimization, I wonder if the same could be implemented for Data.Text.

@Bodigrim
Copy link
Contributor

I don't see an issue here: hPutStrLn does not advertise that it works atomically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants