ZVON > References > Haskell reference |
Intro / Search / ZVON |
| Indexes | Syntax | Prelude | Ratio | Complex | Numeric | Ix | Array | List | Maybe | Char | Monad | >> IO << | Directory | System | Time | Locale | CPUTime | Random |
Module: | IO |
---|---|
Function: | hClose |
Type: | Handle -> IO () |
Description: | hClose hdl makes handle hdl closed. Before the computation finishes, if hdl is writable its buffer is flushed as for hFlush. If the operation fails for any reason, any further operations on the handle will still fail as if hdl had been successfully closed. |
Related: |
Program source: import IO main = do hdl <- openFile "/tmp/foo.txt" WriteMode hPutStr hdl "Hello, world!" hClose hdl hdl <- openFile "/tmp/foo.txt" ReadMode x <- hGetContents hdl putStr x hClose hdl
Output: Hello, world!