mutable byte arrays)
<item>
+<tt/openFileEx/ extends the standard <tr/openFile/ action with support
+for opening binary files.
+
+<item>
<tt/performGC/ triggers an immediate garbage collection
<item>
freezeIOArray :: Ix ix => IOArray ix elt -> IO (Array ix elt)
instance Eq (IOArray ix elt)
+openFileEx :: FilePath -> IOModeEx -> IO Handle
+data IOModeEx = BinaryMode IO.IOMode | TextMode IO.IOMode
+instance Eq IOModeEx
+instance Read IOModeEx
+instance Show IOModeEx
+
performGC :: IO ()
trace :: String -> a -> a
unsafePtrEq :: a -> a -> Bool
data IOMode = ReadMode | WriteMode | AppendMode | ReadWriteMode
deriving (Eq, Ord, Ix, Enum, Read, Show)
+data IOModeEx
+ = BinaryMode IOMode
+ | TextMode IOMode
+ deriving (Eq, Read, Show)
+
openFile :: FilePath -> IOMode -> IO Handle
+openFile fp im = openFileEx fp (TextMode im)
+
+openFileEx :: FilePath -> IOModeEx -> IO Handle
-openFile f m = do
+openFileEx f m = do
ptr <- _ccall_ openFile f m'
if ptr /= ``NULL'' then do
#ifndef __PARALLEL_HASKELL__
_ -> ioError
fail improved_error
where
+ imo = case m of
+ BinaryMode imo -> imo
+ TextMode imo -> imo
+
m' = case m of
+ BinaryMode _ -> imo' ++ "b"
+ TextMode imo -> imo'
+
+ imo' =
+ case imo of
ReadMode -> "r"
WriteMode -> "w"
AppendMode -> "a"
ReadWriteMode -> "r+"
- htype = case m of
+ htype = case imo of
ReadMode -> ReadHandle
WriteMode -> WriteHandle
AppendMode -> AppendHandle