+
+@hTell@ is the lower-level version of @hGetPosn@ - return the
+position, without bundling it together with the handle itself:
+
+\begin{code}
+hTell :: Handle -> IO HandlePosition
+hTell h = do
+ (HandlePosn _ x) <- hGetPosn h
+ return x
+\end{code}
+
+@hSetBinaryMode@ lets you change the translation mode for a handle.
+On some platforms (e.g., Win32) a distinction is made between being in
+'text mode' or 'binary mode', with the former terminating lines
+by \r\n rather than just \n.
+
+Debating the Winnitude or otherwise of such a scheme is less than
+interesting -- it's there, so we have to cope.
+
+A side-effect of calling @hSetBinaryMode@ is that the output buffer
+(if any) is flushed prior to changing the translation mode.
+
+\begin{code}
+hSetBinaryMode :: Handle -> Bool -> IO Bool
+hSetBinaryMode handle is_binary = do
+ -- is_binary = True => set translation mode to binary.
+ wantRWHandle "hSetBinaryMode" handle $ \ handle_ -> do
+ let fo = haFO__ handle_
+ rc <- setBinaryMode fo flg
+ if rc >= 0 then
+ return (int2Bool rc)
+ else
+ constructErrorAndFail "hSetBinaryMode"
+ where
+ flg | is_binary = 1
+ | otherwise = 0
+
+ int2Bool 0 = False
+ int2Bool _ = True
+
+\end{code}