Skip to content

Instantly share code, notes, and snippets.

@nobsun
Last active June 30, 2023 14:36
Show Gist options
  • Save nobsun/da95ada94f5f7932a199381f63f13283 to your computer and use it in GitHub Desktop.
Save nobsun/da95ada94f5f7932a199381f63f13283 to your computer and use it in GitHub Desktop.
module Main where
import System.Environment
import System.IO
main :: IO ()
main = do
{ putStrLn =<< getProgName
; putStr "stdin : "; print =<< hGetBuffering stdin
; putStr "stdout: "; print =<< hGetBuffering stdout
; putStr "stderr: "; print =<< hGetBuffering stderr
}
{- GHCi で起動すると --
>>> main
<interactive>
stdin : NoBuffering
stdout: NoBuffering
stderr: NoBuffering
-- -}
{- runghc で起動すると --
$ runghc buffering_mode.hs
buffering_mode.hs
stdin : LineBuffering
stdout: NoBuffering
stderr: NoBuffering
-- -}
{- コンパイルして実行可能ファイルを起動すると --
$ ghc buffering_mode.hs
$ ./buffering_mode
buffering_mode
stdin : LineBuffering
stdout: LineBuffering
stderr: NoBuffering
-- -}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment