It's not specific to Haskell (e.g. the standard C library does the same thing).
Traditionally, if a file descriptor corresponds to the terminal, buffering is set to line mode, otherwise to block mode. File descriptor type can be checked by the isatty(3)
function -- not sure if it is exported to System.IO
.
And yes, you need to set buffering mode manually if you depend on it.
By the way, you can cheat the system and force block buffering in the command line by running your program as cat | ./prog | cat
.