Skip to content

putStrLn doesn't work correctly with LineBuffering #242

Closed

Description

@domenkozar

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.

Activity

  1. Bodigrim commented on May 18, 2022

    @Bodigrim
    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions