fecf4a51d778a9afef4ba8c0465787499931c4a6
[ghc-hetmet.git] / ghc / misc / examples / io / io014 / Main.hs
1 import IO -- 1.3
2
3 main = 
4     accumulate (map hIsOpen [stdin, stdout, stderr]) >>= \ opens ->
5     print opens >>
6     accumulate (map hIsClosed [stdin, stdout, stderr]) >>= \ closeds ->
7     print closeds >>
8     accumulate (map hIsReadable [stdin, stdout, stderr]) >>= \ readables ->
9     print readables >>
10     accumulate (map hIsWritable [stdin, stdout, stderr]) >>= \ writables ->
11     print writables >>
12     accumulate (map hIsBlockBuffered [stdin, stdout, stderr]) >>= \ buffereds ->
13     print buffereds >>
14     accumulate (map hIsLineBuffered [stdin, stdout, stderr]) >>= \ buffereds ->
15     print buffereds >>
16     accumulate (map hIsNotBuffered [stdin, stdout, stderr]) >>= \ buffereds ->
17     print buffereds
18   where
19     -- these didn't make it into 1.3
20     hIsBlockBuffered h = hGetBuffering h >>= \ b -> return $ case b of { BlockBuffering _ -> True; _ -> False }
21     hIsLineBuffered  h = hGetBuffering h >>= \ b -> return $ case b of { LineBuffering -> True; _ -> False }
22     hIsNotBuffered   h = hGetBuffering h >>= \ b -> return $ case b of { NoBuffering -> True; _ -> False }