<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--Rendered using the Haskell Html Library v0.2--> <HTML ><HEAD ><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" ><TITLE >GHC.IO.Handle</TITLE ><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css" ><SCRIPT SRC="haddock-util.js" TYPE="text/javascript" ></SCRIPT ><SCRIPT TYPE="text/javascript" >window.onload = function () {setSynopsis("mini_GHC-IO-Handle.html")};</SCRIPT ></HEAD ><BODY ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="topbar" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD ><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" " ></TD ><TD CLASS="title" >base-4.2.0.2: Basic libraries</TD ><TD CLASS="topbut" ><A HREF="index.html" >Contents</A ></TD ><TD CLASS="topbut" ><A HREF="doc-index.html" >Index</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="modulebar" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD ><FONT SIZE="6" >GHC.IO.Handle</FONT ></TD ><TD ALIGN="right" ><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="infohead" >Portability</TD ><TD CLASS="infoval" >non-portable</TD ></TR ><TR ><TD CLASS="infohead" >Stability</TD ><TD CLASS="infoval" >provisional</TD ></TR ><TR ><TD CLASS="infohead" >Maintainer</TD ><TD CLASS="infoval" >libraries@haskell.org</TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Description</TD ></TR ><TR ><TD CLASS="doc" >External API for GHC's Handle implementation </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Synopsis</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AHandle" >Handle</A > </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3ABufferMode" >BufferMode</A > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" >= <A HREF="#v%3ANoBuffering" >NoBuffering</A ></TD ></TR ><TR ><TD CLASS="decl" >| <A HREF="#v%3ALineBuffering" >LineBuffering</A ></TD ></TR ><TR ><TD CLASS="decl" >| <A HREF="#v%3ABlockBuffering" >BlockBuffering</A > (<A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="Data-Int.html#t%3AInt" >Int</A >)</TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AmkFileHandle" >mkFileHandle</A > :: (<A HREF="GHC-IO-Device.html#t%3AIODevice" >IODevice</A > dev, <A HREF="GHC-IO-BufferedIO.html#t%3ABufferedIO" >BufferedIO</A > dev, <A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > dev) => dev -> <A HREF="System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="System-IO.html#t%3AIOMode" >IOMode</A > -> <A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="GHC-IO-Encoding-Types.html#t%3ATextEncoding" >TextEncoding</A > -> <A HREF="GHC-IO-Handle.html#t%3ANewlineMode" >NewlineMode</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AmkDuplexHandle" >mkDuplexHandle</A > :: (<A HREF="GHC-IO-Device.html#t%3AIODevice" >IODevice</A > dev, <A HREF="GHC-IO-BufferedIO.html#t%3ABufferedIO" >BufferedIO</A > dev, <A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > dev) => dev -> <A HREF="System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="GHC-IO-Encoding-Types.html#t%3ATextEncoding" >TextEncoding</A > -> <A HREF="GHC-IO-Handle.html#t%3ANewlineMode" >NewlineMode</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhFileSize" >hFileSize</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Prelude.html#t%3AInteger" >Integer</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhSetFileSize" >hSetFileSize</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Prelude.html#t%3AInteger" >Integer</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhIsEOF" >hIsEOF</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhLookAhead" >hLookAhead</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Char.html#t%3AChar" >Char</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhSetBuffering" >hSetBuffering</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="GHC-IO-Handle.html#t%3ABufferMode" >BufferMode</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhSetBinaryMode" >hSetBinaryMode</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Data-Bool.html#t%3ABool" >Bool</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhSetEncoding" >hSetEncoding</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="GHC-IO-Encoding-Types.html#t%3ATextEncoding" >TextEncoding</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhGetEncoding" >hGetEncoding</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > (<A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="GHC-IO-Encoding-Types.html#t%3ATextEncoding" >TextEncoding</A >)</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhFlush" >hFlush</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhFlushAll" >hFlushAll</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhDuplicate" >hDuplicate</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhDuplicateTo" >hDuplicateTo</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhClose" >hClose</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhClose_help" >hClose_help</A > :: Handle__ -> <A HREF="System-IO.html#t%3AIO" >IO</A > (Handle__, <A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="Control-Exception-Base.html#t%3ASomeException" >SomeException</A >)</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >type</SPAN > <A HREF="#t%3AHandlePosition" >HandlePosition</A > = <A HREF="Prelude.html#t%3AInteger" >Integer</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AHandlePosn" >HandlePosn</A > = <A HREF="#v%3AHandlePosn" >HandlePosn</A > <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > <A HREF="GHC-IO-Handle.html#t%3AHandlePosition" >HandlePosition</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhGetPosn" >hGetPosn</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="GHC-IO-Handle.html#t%3AHandlePosn" >HandlePosn</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhSetPosn" >hSetPosn</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandlePosn" >HandlePosn</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3ASeekMode" >SeekMode</A > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" >= <A HREF="#v%3AAbsoluteSeek" >AbsoluteSeek</A ></TD ></TR ><TR ><TD CLASS="decl" >| <A HREF="#v%3ARelativeSeek" >RelativeSeek</A ></TD ></TR ><TR ><TD CLASS="decl" >| <A HREF="#v%3ASeekFromEnd" >SeekFromEnd</A ></TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhSeek" >hSeek</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="GHC-IO-Handle.html#t%3ASeekMode" >SeekMode</A > -> <A HREF="Prelude.html#t%3AInteger" >Integer</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhTell" >hTell</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Prelude.html#t%3AInteger" >Integer</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhIsOpen" >hIsOpen</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhIsClosed" >hIsClosed</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhIsReadable" >hIsReadable</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhIsWritable" >hIsWritable</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhGetBuffering" >hGetBuffering</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="GHC-IO-Handle.html#t%3ABufferMode" >BufferMode</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhIsSeekable" >hIsSeekable</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhSetEcho" >hSetEcho</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Data-Bool.html#t%3ABool" >Bool</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhGetEcho" >hGetEcho</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhIsTerminalDevice" >hIsTerminalDevice</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhSetNewlineMode" >hSetNewlineMode</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="GHC-IO-Handle.html#t%3ANewlineMode" >NewlineMode</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3ANewline" >Newline</A > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" >= <A HREF="#v%3ALF" >LF</A ></TD ></TR ><TR ><TD CLASS="decl" >| <A HREF="#v%3ACRLF" >CRLF</A ></TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3ANewlineMode" >NewlineMode</A > = <A HREF="#v%3ANewlineMode" >NewlineMode</A > {<TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="recfield" ><A HREF="#v%3AinputNL" >inputNL</A > :: <A HREF="GHC-IO-Handle.html#t%3ANewline" >Newline</A ></TD ></TR ><TR ><TD CLASS="recfield" ><A HREF="#v%3AoutputNL" >outputNL</A > :: <A HREF="GHC-IO-Handle.html#t%3ANewline" >Newline</A ></TD ></TR ></TABLE >}</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AnativeNewline" >nativeNewline</A > :: <A HREF="GHC-IO-Handle.html#t%3ANewline" >Newline</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AnoNewlineTranslation" >noNewlineTranslation</A > :: <A HREF="GHC-IO-Handle.html#t%3ANewlineMode" >NewlineMode</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AuniversalNewlineMode" >universalNewlineMode</A > :: <A HREF="GHC-IO-Handle.html#t%3ANewlineMode" >NewlineMode</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AnativeNewlineMode" >nativeNewlineMode</A > :: <A HREF="GHC-IO-Handle.html#t%3ANewlineMode" >NewlineMode</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhShow" >hShow</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhWaitForInput" >hWaitForInput</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Data-Int.html#t%3AInt" >Int</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhGetChar" >hGetChar</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Char.html#t%3AChar" >Char</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhGetLine" >hGetLine</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhGetContents" >hGetContents</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhPutChar" >hPutChar</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Data-Char.html#t%3AChar" >Char</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhPutStr" >hPutStr</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Data-Char.html#t%3AString" >String</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhGetBuf" >hGetBuf</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Foreign-Ptr.html#t%3APtr" >Ptr</A > a -> <A HREF="Data-Int.html#t%3AInt" >Int</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Int.html#t%3AInt" >Int</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhGetBufNonBlocking" >hGetBufNonBlocking</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Foreign-Ptr.html#t%3APtr" >Ptr</A > a -> <A HREF="Data-Int.html#t%3AInt" >Int</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Int.html#t%3AInt" >Int</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhPutBuf" >hPutBuf</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Foreign-Ptr.html#t%3APtr" >Ptr</A > a -> <A HREF="Data-Int.html#t%3AInt" >Int</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhPutBufNonBlocking" >hPutBufNonBlocking</A > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Foreign-Ptr.html#t%3APtr" >Ptr</A > a -> <A HREF="Data-Int.html#t%3AInt" >Int</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Int.html#t%3AInt" >Int</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Documentation</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:Handle" ><A NAME="t%3AHandle" ></A ></A ><B >Handle</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" ><P >Haskell defines operations to read and write characters from and to files, represented by values of type <TT >Handle</TT >. Each value of this type is a <EM >handle</EM >: a record used by the Haskell run-time system to <EM >manage</EM > I/O with file system objects. A handle has at least the following properties: </P ><UL ><LI > whether it manages input or output or both; </LI ><LI > whether it is <EM >open</EM >, <EM >closed</EM > or <EM >semi-closed</EM >; </LI ><LI > whether the object is seekable; </LI ><LI > whether buffering is disabled, or enabled on a line or block basis; </LI ><LI > a buffer (whose length may be zero). </LI ></UL ><P >Most handles will also have a current I/O position indicating where the next input or output operation will occur. A handle is <EM >readable</EM > if it manages only input or both input and output; likewise, it is <EM >writable</EM > if it manages only output or both input and output. A handle is <EM >open</EM > when first allocated. Once it is closed it can no longer be used for either input or output, though an implementation cannot re-use its storage while references remain to it. Handles are in the <TT ><A HREF="Text-Show.html#t%3AShow" >Show</A ></TT > and <TT ><A HREF="Data-Eq.html#t%3AEq" >Eq</A ></TT > classes. The string produced by showing a handle is system dependent; it should include enough information to identify the handle for debugging. A handle is equal according to <TT ><A HREF="Data-Eq.html#v%3A%3D%3D" >==</A ></TT > only to itself; no attempt is made to compare the internal state of different handles for equality. </P ><P >GHC note: a <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT > will be automatically closed when the garbage collector detects that it has become unreferenced by the program. However, relying on this behaviour is not generally recommended: the garbage collector is unpredictable. If possible, use explicit an explicit hClose to close <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >s when they are no longer required. GHC does not currently attempt to free up file descriptors when they have run out, it is your responsibility to ensure that this doesn't happen. </P ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Handle')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:Handle" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Data-Eq.html#t%3AEq" >Eq</A > <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:BufferMode" ><A NAME="t%3ABufferMode" ></A ></A ><B >BufferMode</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" ><P >Three kinds of buffering are supported: line-buffering, block-buffering or no-buffering. These modes have the following effects. For output, items are written out, or <EM >flushed</EM >, from the internal buffer according to the buffer mode: </P ><UL ><LI > <EM >line-buffering</EM >: the entire output buffer is flushed whenever a newline is output, the buffer overflows, a System.IO.hFlush is issued, or the handle is closed. </LI ><LI > <EM >block-buffering</EM >: the entire buffer is written out whenever it overflows, a System.IO.hFlush is issued, or the handle is closed. </LI ><LI > <EM >no-buffering</EM >: output is written immediately, and never stored in the buffer. </LI ></UL ><P >An implementation is free to flush the buffer more frequently, but not less frequently, than specified above. The output buffer is emptied as soon as it has been written out. </P ><P >Similarly, input occurs according to the buffer mode for the handle: </P ><UL ><LI > <EM >line-buffering</EM >: when the buffer for the handle is not empty, the next item is obtained from the buffer; otherwise, when the buffer is empty, characters up to and including the next newline character are read into the buffer. No characters are available until the newline character is available or the buffer is full. </LI ><LI > <EM >block-buffering</EM >: when the buffer for the handle becomes empty, the next block of data is read into the buffer. </LI ><LI > <EM >no-buffering</EM >: the next input item is read and returned. The System.IO.hLookAhead operation implies that even a no-buffered handle may require a one-character buffer. </LI ></UL ><P >The default buffering mode when a handle is opened is implementation-dependent and may depend on the file system object which is attached to that handle. For most implementations, physical files will normally be block-buffered and terminals will normally be line-buffered. </P ></TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:NoBuffering" ><A NAME="v%3ANoBuffering" ></A ></A ><B >NoBuffering</B ></TD ><TD CLASS="rdoc" >buffering is disabled if possible. </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:LineBuffering" ><A NAME="v%3ALineBuffering" ></A ></A ><B >LineBuffering</B ></TD ><TD CLASS="rdoc" >line-buffering should be enabled if possible. </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:BlockBuffering" ><A NAME="v%3ABlockBuffering" ></A ></A ><B >BlockBuffering</B > (<A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="Data-Int.html#t%3AInt" >Int</A >)</TD ><TD CLASS="rdoc" >block-buffering should be enabled if possible. The size of the buffer is <TT >n</TT > items if the argument is <TT ><A HREF="Data-Maybe.html#v%3AJust" >Just</A ></TT > <TT >n</TT > and is otherwise implementation-dependent. </TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:BufferMode')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:BufferMode" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Data-Eq.html#t%3AEq" >Eq</A > <A HREF="GHC-IO-Handle.html#t%3ABufferMode" >BufferMode</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Ord.html#t%3AOrd" >Ord</A > <A HREF="GHC-IO-Handle.html#t%3ABufferMode" >BufferMode</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Read.html#t%3ARead" >Read</A > <A HREF="GHC-IO-Handle.html#t%3ABufferMode" >BufferMode</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="GHC-IO-Handle.html#t%3ABufferMode" >BufferMode</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:mkFileHandle" ><A NAME="v%3AmkFileHandle" ></A ></A ><B >mkFileHandle</B ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="arg" >:: (<A HREF="GHC-IO-Device.html#t%3AIODevice" >IODevice</A > dev, <A HREF="GHC-IO-BufferedIO.html#t%3ABufferedIO" >BufferedIO</A > dev, <A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > dev)</TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="arg" >=> dev</TD ><TD CLASS="rdoc" >the underlying IO device, which must support <TT ><A HREF="GHC-IO-Device.html#t%3AIODevice" >IODevice</A ></TT >, <TT ><A HREF="GHC-IO-BufferedIO.html#t%3ABufferedIO" >BufferedIO</A ></TT > and <TT ><A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A ></TT > </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="System-IO.html#t%3AFilePath" >FilePath</A ></TD ><TD CLASS="rdoc" >a string describing the <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >, e.g. the file path for a file. Used in error messages. </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="System-IO.html#t%3AIOMode" >IOMode</A ></TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="GHC-IO-Encoding-Types.html#t%3ATextEncoding" >TextEncoding</A ></TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="GHC-IO-Handle.html#t%3ANewlineMode" >NewlineMode</A ></TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="ndoc" COLSPAN="2" >makes a new <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT > </TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:mkDuplexHandle" ><A NAME="v%3AmkDuplexHandle" ></A ></A ><B >mkDuplexHandle</B > :: (<A HREF="GHC-IO-Device.html#t%3AIODevice" >IODevice</A > dev, <A HREF="GHC-IO-BufferedIO.html#t%3ABufferedIO" >BufferedIO</A > dev, <A HREF="Data-Typeable.html#t%3ATypeable" >Typeable</A > dev) => dev -> <A HREF="System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="GHC-IO-Encoding-Types.html#t%3ATextEncoding" >TextEncoding</A > -> <A HREF="GHC-IO-Handle.html#t%3ANewlineMode" >NewlineMode</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TD ></TR ><TR ><TD CLASS="doc" >like <TT ><A HREF="GHC-IO-Handle.html#v%3AmkFileHandle" >mkFileHandle</A ></TT >, except that a <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT > is created with two independent buffers, one for reading and one for writing. Used for full-dupliex streams, such as network sockets. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hFileSize" ><A NAME="v%3AhFileSize" ></A ></A ><B >hFileSize</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Prelude.html#t%3AInteger" >Integer</A ></TD ></TR ><TR ><TD CLASS="doc" >For a handle <TT >hdl</TT > which attached to a physical file, <TT ><A HREF="GHC-IO-Handle.html#v%3AhFileSize" >hFileSize</A ></TT > <TT >hdl</TT > returns the size of that file in 8-bit bytes. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hSetFileSize" ><A NAME="v%3AhSetFileSize" ></A ></A ><B >hSetFileSize</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Prelude.html#t%3AInteger" >Integer</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" ><TT ><A HREF="GHC-IO-Handle.html#v%3AhSetFileSize" >hSetFileSize</A ></TT > <TT >hdl</TT > <TT >size</TT > truncates the physical file with handle <TT >hdl</TT > to <TT >size</TT > bytes. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hIsEOF" ><A NAME="v%3AhIsEOF" ></A ></A ><B >hIsEOF</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >For a readable handle <TT >hdl</TT >, <TT ><A HREF="GHC-IO-Handle.html#v%3AhIsEOF" >hIsEOF</A ></TT > <TT >hdl</TT > returns <TT ><A HREF="Data-Bool.html#v%3ATrue" >True</A ></TT > if no further input can be taken from <TT >hdl</TT > or for a physical file, if the current I/O position is equal to the length of the file. Otherwise, it returns <TT ><A HREF="Data-Bool.html#v%3AFalse" >False</A ></TT >. </P ><P >NOTE: <TT ><A HREF="GHC-IO-Handle.html#v%3AhIsEOF" >hIsEOF</A ></TT > may block, because it has to attempt to read from the stream to determine whether there is any more data to be read. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hLookAhead" ><A NAME="v%3AhLookAhead" ></A ></A ><B >hLookAhead</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Char.html#t%3AChar" >Char</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Computation <TT ><A HREF="GHC-IO-Handle.html#v%3AhLookAhead" >hLookAhead</A ></TT > returns the next character from the handle without removing it from the input buffer, blocking until a character is available. </P ><P >This operation may fail with: </P ><UL ><LI > isEOFError if the end of file has been reached. </LI ></UL ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hSetBuffering" ><A NAME="v%3AhSetBuffering" ></A ></A ><B >hSetBuffering</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="GHC-IO-Handle.html#t%3ABufferMode" >BufferMode</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Computation <TT ><A HREF="GHC-IO-Handle.html#v%3AhSetBuffering" >hSetBuffering</A ></TT > <TT >hdl mode</TT > sets the mode of buffering for handle <TT >hdl</TT > on subsequent reads and writes. </P ><P >If the buffer mode is changed from <TT ><A HREF="GHC-IO-Handle.html#v%3ABlockBuffering" >BlockBuffering</A ></TT > or <TT ><A HREF="GHC-IO-Handle.html#v%3ALineBuffering" >LineBuffering</A ></TT > to <TT ><A HREF="GHC-IO-Handle.html#v%3ANoBuffering" >NoBuffering</A ></TT >, then </P ><UL ><LI > if <TT >hdl</TT > is writable, the buffer is flushed as for <TT ><A HREF="GHC-IO-Handle.html#v%3AhFlush" >hFlush</A ></TT >; </LI ><LI > if <TT >hdl</TT > is not writable, the contents of the buffer is discarded. </LI ></UL ><P >This operation may fail with: </P ><UL ><LI > isPermissionError if the handle has already been used for reading or writing and the implementation does not allow the buffering mode to be changed. </LI ></UL ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hSetBinaryMode" ><A NAME="v%3AhSetBinaryMode" ></A ></A ><B >hSetBinaryMode</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Data-Bool.html#t%3ABool" >Bool</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Select binary mode (<TT ><A HREF="Data-Bool.html#v%3ATrue" >True</A ></TT >) or text mode (<TT ><A HREF="Data-Bool.html#v%3AFalse" >False</A ></TT >) on a open handle. (See also openBinaryFile.) </P ><P >This has the same effect as calling <TT ><A HREF="GHC-IO-Handle.html#v%3AhSetEncoding" >hSetEncoding</A ></TT > with <TT ><A HREF="GHC-IO-Encoding.html#v%3Alatin1" >latin1</A ></TT >, together with <TT ><A HREF="GHC-IO-Handle.html#v%3AhSetNewlineMode" >hSetNewlineMode</A ></TT > with <TT ><A HREF="GHC-IO-Handle.html#v%3AnoNewlineTranslation" >noNewlineTranslation</A ></TT >. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hSetEncoding" ><A NAME="v%3AhSetEncoding" ></A ></A ><B >hSetEncoding</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="GHC-IO-Encoding-Types.html#t%3ATextEncoding" >TextEncoding</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >The action <TT ><A HREF="GHC-IO-Handle.html#v%3AhSetEncoding" >hSetEncoding</A ></TT > <TT >hdl</TT > <TT >encoding</TT > changes the text encoding for the handle <TT >hdl</TT > to <TT >encoding</TT >. The default encoding when a <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT > is created is <TT ><A HREF="GHC-IO-Encoding.html#v%3AlocaleEncoding" >localeEncoding</A ></TT >, namely the default encoding for the current locale. </P ><P >To create a <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT > with no encoding at all, use openBinaryFile. To stop further encoding or decoding on an existing <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >, use <TT ><A HREF="GHC-IO-Handle.html#v%3AhSetBinaryMode" >hSetBinaryMode</A ></TT >. </P ><P ><TT ><A HREF="GHC-IO-Handle.html#v%3AhSetEncoding" >hSetEncoding</A ></TT > may need to flush buffered data in order to change the encoding. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hGetEncoding" ><A NAME="v%3AhGetEncoding" ></A ></A ><B >hGetEncoding</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > (<A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="GHC-IO-Encoding-Types.html#t%3ATextEncoding" >TextEncoding</A >)</TD ></TR ><TR ><TD CLASS="doc" ><P >Return the current <TT ><A HREF="GHC-IO-Encoding-Types.html#t%3ATextEncoding" >TextEncoding</A ></TT > for the specified <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >, or <TT ><A HREF="Data-Maybe.html#v%3ANothing" >Nothing</A ></TT > if the <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT > is in binary mode. </P ><P >Note that the <TT ><A HREF="GHC-IO-Encoding-Types.html#t%3ATextEncoding" >TextEncoding</A ></TT > remembers nothing about the state of the encoder/decoder in use on this <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >. For example, if the encoding in use is UTF-16, then using <TT ><A HREF="GHC-IO-Handle.html#v%3AhGetEncoding" >hGetEncoding</A ></TT > and <TT ><A HREF="GHC-IO-Handle.html#v%3AhSetEncoding" >hSetEncoding</A ></TT > to save and restore the encoding may result in an extra byte-order-mark being written to the file. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hFlush" ><A NAME="v%3AhFlush" ></A ></A ><B >hFlush</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >The action <TT ><A HREF="GHC-IO-Handle.html#v%3AhFlush" >hFlush</A ></TT > <TT >hdl</TT > causes any items buffered for output in handle <TT >hdl</TT > to be sent immediately to the operating system. </P ><P >This operation may fail with: </P ><UL ><LI > isFullError if the device is full; </LI ><LI > isPermissionError if a system resource limit would be exceeded. It is unspecified whether the characters in the buffer are discarded or retained under these circumstances. </LI ></UL ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hFlushAll" ><A NAME="v%3AhFlushAll" ></A ></A ><B >hFlushAll</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >The action <TT ><A HREF="GHC-IO-Handle.html#v%3AhFlushAll" >hFlushAll</A ></TT > <TT >hdl</TT > flushes all buffered data in <TT >hdl</TT >, including any buffered read data. Buffered read data is flushed by seeking the file position back to the point before the bufferred data was read, and hence only works if <TT >hdl</TT > is seekable (see <TT ><A HREF="GHC-IO-Handle.html#v%3AhIsSeekable" >hIsSeekable</A ></TT >). </P ><P >This operation may fail with: </P ><UL ><LI > isFullError if the device is full; </LI ><LI > isPermissionError if a system resource limit would be exceeded. It is unspecified whether the characters in the buffer are discarded or retained under these circumstances; </LI ><LI > isIllegalOperation if <TT >hdl</TT > has buffered read data, and is not seekable. </LI ></UL ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hDuplicate" ><A NAME="v%3AhDuplicate" ></A ></A ><B >hDuplicate</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TD ></TR ><TR ><TD CLASS="doc" >Returns a duplicate of the original handle, with its own buffer. The two Handles will share a file pointer, however. The original handle's buffer is flushed, including discarding any input data, before the handle is duplicated. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hDuplicateTo" ><A NAME="v%3AhDuplicateTo" ></A ></A ><B >hDuplicateTo</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Makes the second handle a duplicate of the first handle. The second handle will be closed first, if it is not already. </P ><P >This can be used to retarget the standard Handles, for example: </P ><PRE > do h <- openFile "mystdout" WriteMode hDuplicateTo h stdout </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hClose" ><A NAME="v%3AhClose" ></A ></A ><B >hClose</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" >Computation <TT ><A HREF="GHC-IO-Handle.html#v%3AhClose" >hClose</A ></TT > <TT >hdl</TT > makes handle <TT >hdl</TT > closed. Before the computation finishes, if <TT >hdl</TT > is writable its buffer is flushed as for <TT ><A HREF="GHC-IO-Handle.html#v%3AhFlush" >hFlush</A ></TT >. Performing <TT ><A HREF="GHC-IO-Handle.html#v%3AhClose" >hClose</A ></TT > on a handle that has already been closed has no effect; doing so is not an error. All other operations on a closed handle will fail. If <TT ><A HREF="GHC-IO-Handle.html#v%3AhClose" >hClose</A ></TT > fails for any reason, any further operations (apart from <TT ><A HREF="GHC-IO-Handle.html#v%3AhClose" >hClose</A ></TT >) on the handle will still fail as if <TT >hdl</TT > had been successfully closed. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hClose_help" ><A NAME="v%3AhClose_help" ></A ></A ><B >hClose_help</B > :: Handle__ -> <A HREF="System-IO.html#t%3AIO" >IO</A > (Handle__, <A HREF="Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="Control-Exception-Base.html#t%3ASomeException" >SomeException</A >)</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >type</SPAN > <A NAME="t:HandlePosition" ><A NAME="t%3AHandlePosition" ></A ></A ><B >HandlePosition</B > = <A HREF="Prelude.html#t%3AInteger" >Integer</A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:HandlePosn" ><A NAME="t%3AHandlePosn" ></A ></A ><B >HandlePosn</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:HandlePosn" ><A NAME="v%3AHandlePosn" ></A ></A ><B >HandlePosn</B > <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > <A HREF="GHC-IO-Handle.html#t%3AHandlePosition" >HandlePosition</A ></TD ><TD CLASS="rdoc" ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:HandlePosn')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:HandlePosn" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Data-Eq.html#t%3AEq" >Eq</A > <A HREF="GHC-IO-Handle.html#t%3AHandlePosn" >HandlePosn</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="GHC-IO-Handle.html#t%3AHandlePosn" >HandlePosn</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hGetPosn" ><A NAME="v%3AhGetPosn" ></A ></A ><B >hGetPosn</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="GHC-IO-Handle.html#t%3AHandlePosn" >HandlePosn</A ></TD ></TR ><TR ><TD CLASS="doc" >Computation <TT ><A HREF="GHC-IO-Handle.html#v%3AhGetPosn" >hGetPosn</A ></TT > <TT >hdl</TT > returns the current I/O position of <TT >hdl</TT > as a value of the abstract type <TT ><A HREF="GHC-IO-Handle.html#t%3AHandlePosn" >HandlePosn</A ></TT >. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hSetPosn" ><A NAME="v%3AhSetPosn" ></A ></A ><B >hSetPosn</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandlePosn" >HandlePosn</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >If a call to <TT ><A HREF="GHC-IO-Handle.html#v%3AhGetPosn" >hGetPosn</A ></TT > <TT >hdl</TT > returns a position <TT >p</TT >, then computation <TT ><A HREF="GHC-IO-Handle.html#v%3AhSetPosn" >hSetPosn</A ></TT > <TT >p</TT > sets the position of <TT >hdl</TT > to the position it held at the time of the call to <TT ><A HREF="GHC-IO-Handle.html#v%3AhGetPosn" >hGetPosn</A ></TT >. </P ><P >This operation may fail with: </P ><UL ><LI > isPermissionError if a system resource limit would be exceeded. </LI ></UL ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:SeekMode" ><A NAME="t%3ASeekMode" ></A ></A ><B >SeekMode</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >A mode that determines the effect of hSeek <TT >hdl mode i</TT >, as follows: </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:AbsoluteSeek" ><A NAME="v%3AAbsoluteSeek" ></A ></A ><B >AbsoluteSeek</B ></TD ><TD CLASS="rdoc" >the position of <TT >hdl</TT > is set to <TT >i</TT >. </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:RelativeSeek" ><A NAME="v%3ARelativeSeek" ></A ></A ><B >RelativeSeek</B ></TD ><TD CLASS="rdoc" >the position of <TT >hdl</TT > is set to offset <TT >i</TT > from the current position. </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:SeekFromEnd" ><A NAME="v%3ASeekFromEnd" ></A ></A ><B >SeekFromEnd</B ></TD ><TD CLASS="rdoc" >the position of <TT >hdl</TT > is set to offset <TT >i</TT > from the end of the file. </TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:SeekMode')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:SeekMode" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Prelude.html#t%3AEnum" >Enum</A > <A HREF="GHC-IO-Handle.html#t%3ASeekMode" >SeekMode</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Eq.html#t%3AEq" >Eq</A > <A HREF="GHC-IO-Handle.html#t%3ASeekMode" >SeekMode</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Ord.html#t%3AOrd" >Ord</A > <A HREF="GHC-IO-Handle.html#t%3ASeekMode" >SeekMode</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Read.html#t%3ARead" >Read</A > <A HREF="GHC-IO-Handle.html#t%3ASeekMode" >SeekMode</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Text-Show.html#t%3AShow" >Show</A > <A HREF="GHC-IO-Handle.html#t%3ASeekMode" >SeekMode</A ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="Data-Ix.html#t%3AIx" >Ix</A > <A HREF="GHC-IO-Handle.html#t%3ASeekMode" >SeekMode</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hSeek" ><A NAME="v%3AhSeek" ></A ></A ><B >hSeek</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="GHC-IO-Handle.html#t%3ASeekMode" >SeekMode</A > -> <A HREF="Prelude.html#t%3AInteger" >Integer</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Computation <TT ><A HREF="GHC-IO-Handle.html#v%3AhSeek" >hSeek</A ></TT > <TT >hdl mode i</TT > sets the position of handle <TT >hdl</TT > depending on <TT >mode</TT >. The offset <TT >i</TT > is given in terms of 8-bit bytes. </P ><P >If <TT >hdl</TT > is block- or line-buffered, then seeking to a position which is not in the current buffer will first cause any items in the output buffer to be written to the device, and then cause the input buffer to be discarded. Some handles may not be seekable (see <TT ><A HREF="GHC-IO-Handle.html#v%3AhIsSeekable" >hIsSeekable</A ></TT >), or only support a subset of the possible positioning operations (for instance, it may only be possible to seek to the end of a tape, or to a positive offset from the beginning or current position). It is not possible to set a negative I/O position, or for a physical file, an I/O position beyond the current end-of-file. </P ><P >This operation may fail with: </P ><UL ><LI > isPermissionError if a system resource limit would be exceeded. </LI ></UL ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hTell" ><A NAME="v%3AhTell" ></A ></A ><B >hTell</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Prelude.html#t%3AInteger" >Integer</A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hIsOpen" ><A NAME="v%3AhIsOpen" ></A ></A ><B >hIsOpen</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hIsClosed" ><A NAME="v%3AhIsClosed" ></A ></A ><B >hIsClosed</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hIsReadable" ><A NAME="v%3AhIsReadable" ></A ></A ><B >hIsReadable</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hIsWritable" ><A NAME="v%3AhIsWritable" ></A ></A ><B >hIsWritable</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hGetBuffering" ><A NAME="v%3AhGetBuffering" ></A ></A ><B >hGetBuffering</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="GHC-IO-Handle.html#t%3ABufferMode" >BufferMode</A ></TD ></TR ><TR ><TD CLASS="doc" >Computation <TT ><A HREF="GHC-IO-Handle.html#v%3AhGetBuffering" >hGetBuffering</A ></TT > <TT >hdl</TT > returns the current buffering mode for <TT >hdl</TT >. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hIsSeekable" ><A NAME="v%3AhIsSeekable" ></A ></A ><B >hIsSeekable</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hSetEcho" ><A NAME="v%3AhSetEcho" ></A ></A ><B >hSetEcho</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Data-Bool.html#t%3ABool" >Bool</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" >Set the echoing status of a handle connected to a terminal. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hGetEcho" ><A NAME="v%3AhGetEcho" ></A ></A ><B >hGetEcho</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="doc" >Get the echoing status of a handle connected to a terminal. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hIsTerminalDevice" ><A NAME="v%3AhIsTerminalDevice" ></A ></A ><B >hIsTerminalDevice</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="doc" >Is the handle connected to a terminal? </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hSetNewlineMode" ><A NAME="v%3AhSetNewlineMode" ></A ></A ><B >hSetNewlineMode</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="GHC-IO-Handle.html#t%3ANewlineMode" >NewlineMode</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" >Set the <TT ><A HREF="GHC-IO-Handle.html#t%3ANewlineMode" >NewlineMode</A ></TT > on the specified <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >. All buffered data is flushed first. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:Newline" ><A NAME="t%3ANewline" ></A ></A ><B >Newline</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >The representation of a newline in the external file or stream. </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:LF" ><A NAME="v%3ALF" ></A ></A ><B >LF</B ></TD ><TD CLASS="rdoc" >'\n' </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:CRLF" ><A NAME="v%3ACRLF" ></A ></A ><B >CRLF</B ></TD ><TD CLASS="rdoc" >'\r\n' </TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Newline')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:Newline" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Data-Eq.html#t%3AEq" >Eq</A > <A HREF="GHC-IO-Handle.html#t%3ANewline" >Newline</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:NewlineMode" ><A NAME="t%3ANewlineMode" ></A ></A ><B >NewlineMode</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="ndoc" >Specifies the translation, if any, of newline characters between internal Strings and the external file or stream. Haskell Strings are assumed to represent newlines with the '\n' character; the newline mode specifies how to translate '\n' on output, and what to translate into '\n' on input. </TD ></TR ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="5" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:NewlineMode" ><A NAME="v%3ANewlineMode" ></A ></A ><B >NewlineMode</B ></TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="body" COLSPAN="2" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:inputNL" ><A NAME="v%3AinputNL" ></A ></A ><B >inputNL</B > :: <A HREF="GHC-IO-Handle.html#t%3ANewline" >Newline</A ></TD ><TD CLASS="rdoc" >the representation of newlines on input </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:outputNL" ><A NAME="v%3AoutputNL" ></A ></A ><B >outputNL</B > :: <A HREF="GHC-IO-Handle.html#t%3ANewline" >Newline</A ></TD ><TD CLASS="rdoc" >the representation of newlines on output </TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="section4" ><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:NewlineMode')" ALT="show/hide" > Instances</TD ></TR ><TR ><TD CLASS="body" ><DIV ID="i:NewlineMode" STYLE="display:block;" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="Data-Eq.html#t%3AEq" >Eq</A > <A HREF="GHC-IO-Handle.html#t%3ANewlineMode" >NewlineMode</A ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:nativeNewline" ><A NAME="v%3AnativeNewline" ></A ></A ><B >nativeNewline</B > :: <A HREF="GHC-IO-Handle.html#t%3ANewline" >Newline</A ></TD ></TR ><TR ><TD CLASS="doc" >The native newline representation for the current platform: <TT ><A HREF="GHC-IO-Handle.html#v%3ALF" >LF</A ></TT > on Unix systems, <TT ><A HREF="GHC-IO-Handle.html#v%3ACRLF" >CRLF</A ></TT > on Windows. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:noNewlineTranslation" ><A NAME="v%3AnoNewlineTranslation" ></A ></A ><B >noNewlineTranslation</B > :: <A HREF="GHC-IO-Handle.html#t%3ANewlineMode" >NewlineMode</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Do no newline translation at all. </P ><PRE > noNewlineTranslation = NewlineMode { inputNL = LF, outputNL = LF } </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:universalNewlineMode" ><A NAME="v%3AuniversalNewlineMode" ></A ></A ><B >universalNewlineMode</B > :: <A HREF="GHC-IO-Handle.html#t%3ANewlineMode" >NewlineMode</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Map '\r\n' into '\n' on input, and '\n' to the native newline represetnation on output. This mode can be used on any platform, and works with text files using any newline convention. The downside is that <TT >readFile >>= writeFile</TT > might yield a different file. </P ><PRE > universalNewlineMode = NewlineMode { inputNL = CRLF, outputNL = nativeNewline } </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:nativeNewlineMode" ><A NAME="v%3AnativeNewlineMode" ></A ></A ><B >nativeNewlineMode</B > :: <A HREF="GHC-IO-Handle.html#t%3ANewlineMode" >NewlineMode</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Use the native newline representation on both input and output </P ><PRE > nativeNewlineMode = NewlineMode { inputNL = nativeNewline outputNL = nativeNewline } </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hShow" ><A NAME="v%3AhShow" ></A ></A ><B >hShow</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="doc" ><TT ><A HREF="GHC-IO-Handle.html#v%3AhShow" >hShow</A ></TT > is in the <TT ><A HREF="System-IO.html#t%3AIO" >IO</A ></TT > monad, and gives more comprehensive output than the (pure) instance of <TT ><A HREF="Text-Show.html#t%3AShow" >Show</A ></TT > for <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hWaitForInput" ><A NAME="v%3AhWaitForInput" ></A ></A ><B >hWaitForInput</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Data-Int.html#t%3AInt" >Int</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Computation <TT ><A HREF="GHC-IO-Handle.html#v%3AhWaitForInput" >hWaitForInput</A ></TT > <TT >hdl t</TT > waits until input is available on handle <TT >hdl</TT >. It returns <TT ><A HREF="Data-Bool.html#v%3ATrue" >True</A ></TT > as soon as input is available on <TT >hdl</TT >, or <TT ><A HREF="Data-Bool.html#v%3AFalse" >False</A ></TT > if no input is available within <TT >t</TT > milliseconds. </P ><P >If <TT >t</TT > is less than zero, then <TT >hWaitForInput</TT > waits indefinitely. </P ><P >This operation may fail with: </P ><UL ><LI > <TT ><A HREF="System-IO-Error.html#v%3AisEOFError" >isEOFError</A ></TT > if the end of file has been reached. </LI ></UL ><P >NOTE for GHC users: unless you use the <TT >-threaded</TT > flag, <TT >hWaitForInput t</TT > where <TT >t >= 0</TT > will block all other Haskell threads for the duration of the call. It behaves like a <TT >safe</TT > foreign call in this respect. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hGetChar" ><A NAME="v%3AhGetChar" ></A ></A ><B >hGetChar</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Char.html#t%3AChar" >Char</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Computation <TT ><A HREF="GHC-IO-Handle.html#v%3AhGetChar" >hGetChar</A ></TT > <TT >hdl</TT > reads a character from the file or channel managed by <TT >hdl</TT >, blocking until a character is available. </P ><P >This operation may fail with: </P ><UL ><LI > <TT ><A HREF="System-IO-Error.html#v%3AisEOFError" >isEOFError</A ></TT > if the end of file has been reached. </LI ></UL ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hGetLine" ><A NAME="v%3AhGetLine" ></A ></A ><B >hGetLine</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Computation <TT ><A HREF="GHC-IO-Handle.html#v%3AhGetLine" >hGetLine</A ></TT > <TT >hdl</TT > reads a line from the file or channel managed by <TT >hdl</TT >. </P ><P >This operation may fail with: </P ><UL ><LI > <TT ><A HREF="System-IO-Error.html#v%3AisEOFError" >isEOFError</A ></TT > if the end of file is encountered when reading the <EM >first</EM > character of the line. </LI ></UL ><P >If <TT ><A HREF="GHC-IO-Handle.html#v%3AhGetLine" >hGetLine</A ></TT > encounters end-of-file at any other point while reading in a line, it is treated as a line terminator and the (partial) line is returned. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hGetContents" ><A NAME="v%3AhGetContents" ></A ></A ><B >hGetContents</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Computation <TT ><A HREF="GHC-IO-Handle.html#v%3AhGetContents" >hGetContents</A ></TT > <TT >hdl</TT > returns the list of characters corresponding to the unread portion of the channel or file managed by <TT >hdl</TT >, which is put into an intermediate state, <EM >semi-closed</EM >. In this state, <TT >hdl</TT > is effectively closed, but items are read from <TT >hdl</TT > on demand and accumulated in a special list returned by <TT ><A HREF="GHC-IO-Handle.html#v%3AhGetContents" >hGetContents</A ></TT > <TT >hdl</TT >. </P ><P >Any operation that fails because a handle is closed, also fails if a handle is semi-closed. The only exception is hClose. A semi-closed handle becomes closed: </P ><UL ><LI > if hClose is applied to it; </LI ><LI > if an I/O error occurs when reading an item from the handle; </LI ><LI > or once the entire contents of the handle has been read. </LI ></UL ><P >Once a semi-closed handle becomes closed, the contents of the associated list becomes fixed. The contents of this final list is only partially specified: it will contain at least all the items of the stream that were evaluated prior to the handle becoming closed. </P ><P >Any I/O errors encountered while a handle is semi-closed are simply discarded. </P ><P >This operation may fail with: </P ><UL ><LI > <TT ><A HREF="System-IO-Error.html#v%3AisEOFError" >isEOFError</A ></TT > if the end of file has been reached. </LI ></UL ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hPutChar" ><A NAME="v%3AhPutChar" ></A ></A ><B >hPutChar</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Data-Char.html#t%3AChar" >Char</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Computation <TT ><A HREF="GHC-IO-Handle.html#v%3AhPutChar" >hPutChar</A ></TT > <TT >hdl ch</TT > writes the character <TT >ch</TT > to the file or channel managed by <TT >hdl</TT >. Characters may be buffered if buffering is enabled for <TT >hdl</TT >. </P ><P >This operation may fail with: </P ><UL ><LI > <TT ><A HREF="System-IO-Error.html#v%3AisFullError" >isFullError</A ></TT > if the device is full; or </LI ><LI > <TT ><A HREF="System-IO-Error.html#v%3AisPermissionError" >isPermissionError</A ></TT > if another system resource limit would be exceeded. </LI ></UL ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hPutStr" ><A NAME="v%3AhPutStr" ></A ></A ><B >hPutStr</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Data-Char.html#t%3AString" >String</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Computation <TT ><A HREF="GHC-IO-Handle.html#v%3AhPutStr" >hPutStr</A ></TT > <TT >hdl s</TT > writes the string <TT >s</TT > to the file or channel managed by <TT >hdl</TT >. </P ><P >This operation may fail with: </P ><UL ><LI > <TT ><A HREF="System-IO-Error.html#v%3AisFullError" >isFullError</A ></TT > if the device is full; or </LI ><LI > <TT ><A HREF="System-IO-Error.html#v%3AisPermissionError" >isPermissionError</A ></TT > if another system resource limit would be exceeded. </LI ></UL ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hGetBuf" ><A NAME="v%3AhGetBuf" ></A ></A ><B >hGetBuf</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Foreign-Ptr.html#t%3APtr" >Ptr</A > a -> <A HREF="Data-Int.html#t%3AInt" >Int</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Int.html#t%3AInt" >Int</A ></TD ></TR ><TR ><TD CLASS="doc" ><P ><TT ><A HREF="GHC-IO-Handle.html#v%3AhGetBuf" >hGetBuf</A ></TT > <TT >hdl buf count</TT > reads data from the handle <TT >hdl</TT > into the buffer <TT >buf</TT > until either EOF is reached or <TT >count</TT > 8-bit bytes have been read. It returns the number of bytes actually read. This may be zero if EOF was reached before any data was read (or if <TT >count</TT > is zero). </P ><P ><TT ><A HREF="GHC-IO-Handle.html#v%3AhGetBuf" >hGetBuf</A ></TT > ignores whatever TextEncoding the <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT > is currently using, and reads bytes directly from the underlying IO device. </P ><P ><TT ><A HREF="GHC-IO-Handle.html#v%3AhGetBuf" >hGetBuf</A ></TT > never raises an EOF exception, instead it returns a value smaller than <TT >count</TT >. </P ><P >If the handle is a pipe or socket, and the writing end is closed, <TT ><A HREF="GHC-IO-Handle.html#v%3AhGetBuf" >hGetBuf</A ></TT > will behave as if EOF was reached. </P ><P ><TT ><A HREF="GHC-IO-Handle.html#v%3AhGetBuf" >hGetBuf</A ></TT > ignores the prevailing TextEncoding and <TT ><A HREF="GHC-IO-Handle.html#t%3ANewlineMode" >NewlineMode</A ></TT > on the <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >, and reads bytes directly. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hGetBufNonBlocking" ><A NAME="v%3AhGetBufNonBlocking" ></A ></A ><B >hGetBufNonBlocking</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Foreign-Ptr.html#t%3APtr" >Ptr</A > a -> <A HREF="Data-Int.html#t%3AInt" >Int</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Int.html#t%3AInt" >Int</A ></TD ></TR ><TR ><TD CLASS="doc" ><P ><TT ><A HREF="GHC-IO-Handle.html#v%3AhGetBufNonBlocking" >hGetBufNonBlocking</A ></TT > <TT >hdl buf count</TT > reads data from the handle <TT >hdl</TT > into the buffer <TT >buf</TT > until either EOF is reached, or <TT >count</TT > 8-bit bytes have been read, or there is no more data available to read immediately. </P ><P ><TT ><A HREF="GHC-IO-Handle.html#v%3AhGetBufNonBlocking" >hGetBufNonBlocking</A ></TT > is identical to <TT ><A HREF="GHC-IO-Handle.html#v%3AhGetBuf" >hGetBuf</A ></TT >, except that it will never block waiting for data to become available, instead it returns only whatever data is available. To wait for data to arrive before calling <TT ><A HREF="GHC-IO-Handle.html#v%3AhGetBufNonBlocking" >hGetBufNonBlocking</A ></TT >, use <TT ><A HREF="GHC-IO-Handle.html#v%3AhWaitForInput" >hWaitForInput</A ></TT >. </P ><P ><TT ><A HREF="GHC-IO-Handle.html#v%3AhGetBufNonBlocking" >hGetBufNonBlocking</A ></TT > ignores whatever TextEncoding the <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT > is currently using, and reads bytes directly from the underlying IO device. </P ><P >If the handle is a pipe or socket, and the writing end is closed, <TT ><A HREF="GHC-IO-Handle.html#v%3AhGetBufNonBlocking" >hGetBufNonBlocking</A ></TT > will behave as if EOF was reached. </P ><P ><TT ><A HREF="GHC-IO-Handle.html#v%3AhGetBufNonBlocking" >hGetBufNonBlocking</A ></TT > ignores the prevailing TextEncoding and <TT ><A HREF="GHC-IO-Handle.html#t%3ANewlineMode" >NewlineMode</A ></TT > on the <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >, and reads bytes directly. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hPutBuf" ><A NAME="v%3AhPutBuf" ></A ></A ><B >hPutBuf</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Foreign-Ptr.html#t%3APtr" >Ptr</A > a -> <A HREF="Data-Int.html#t%3AInt" >Int</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="../ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" ><P ><TT ><A HREF="GHC-IO-Handle.html#v%3AhPutBuf" >hPutBuf</A ></TT > <TT >hdl buf count</TT > writes <TT >count</TT > 8-bit bytes from the buffer <TT >buf</TT > to the handle <TT >hdl</TT >. It returns (). </P ><P ><TT ><A HREF="GHC-IO-Handle.html#v%3AhPutBuf" >hPutBuf</A ></TT > ignores any text encoding that applies to the <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >, writing the bytes directly to the underlying file or device. </P ><P ><TT ><A HREF="GHC-IO-Handle.html#v%3AhPutBuf" >hPutBuf</A ></TT > ignores the prevailing TextEncoding and <TT ><A HREF="GHC-IO-Handle.html#t%3ANewlineMode" >NewlineMode</A ></TT > on the <TT ><A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >, and writes bytes directly. </P ><P >This operation may fail with: </P ><UL ><LI > <TT >ResourceVanished</TT > if the handle is a pipe or socket, and the reading end is closed. (If this is a POSIX system, and the program has not asked to ignore SIGPIPE, then a SIGPIPE may be delivered instead, whose default action is to terminate the program). </LI ></UL ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hPutBufNonBlocking" ><A NAME="v%3AhPutBufNonBlocking" ></A ></A ><B >hPutBufNonBlocking</B > :: <A HREF="GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="Foreign-Ptr.html#t%3APtr" >Ptr</A > a -> <A HREF="Data-Int.html#t%3AInt" >Int</A > -> <A HREF="System-IO.html#t%3AIO" >IO</A > <A HREF="Data-Int.html#t%3AInt" >Int</A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="botbar" >Produced by <A HREF="http://www.haskell.org/haddock/" >Haddock</A > version 2.6.1</TD ></TR ></TABLE ></BODY ></HTML >