Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gesh
GHC
Commits
74cd7228
Commit
74cd7228
authored
27 years ago
by
sof
Browse files
Options
Downloads
Patches
Plain Diff
[project @ 1998-03-12 08:56:24 by sof]
Added IOExts.openFileEx + IOExts.IOModeEx
parent
aa4f16de
Loading
Loading
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ghc/docs/libraries/libs.sgml
+10
-0
10 additions, 0 deletions
ghc/docs/libraries/libs.sgml
ghc/lib/exts/IOExts.lhs
+5
-0
5 additions, 0 deletions
ghc/lib/exts/IOExts.lhs
ghc/lib/std/PrelHandle.lhs
+19
-2
19 additions, 2 deletions
ghc/lib/std/PrelHandle.lhs
with
34 additions
and
2 deletions
ghc/docs/libraries/libs.sgml
+
10
−
0
View file @
74cd7228
...
...
@@ -183,6 +183,10 @@ described in <cite id="ImperativeFP">
References (aka mutable variables) and mutable arrays (but no form of
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
...
...
@@ -248,6 +252,12 @@ writeIOArray :: Ix ix => IOArray ix elt -> ix -> elt -> IO ()
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
...
...
This diff is collapsed.
Click to expand it.
ghc/lib/exts/IOExts.lhs
+
5
−
0
View file @
74cd7228
...
...
@@ -25,6 +25,9 @@ module IOExts
, readIOArray
, writeIOArray
, freezeIOArray
, openFileEx
, IOModeEx(..)
, trace
, performGC
...
...
@@ -36,6 +39,7 @@ module IOExts
\begin{code}
import PrelBase
import PrelIOBase
import PrelHandle ( openFileEx, IOModeEx(..) )
import PrelST
import PrelUnsafe
import PrelArr
...
...
@@ -84,3 +88,4 @@ writeIOArray (IOArray arr) ix elt = stToIO (writeArray arr ix elt)
freezeIOArray (IOArray arr) = stToIO (freezeArray arr)
\end{code}
This diff is collapsed.
Click to expand it.
ghc/lib/std/PrelHandle.lhs
+
19
−
2
View file @
74cd7228
...
...
@@ -186,9 +186,17 @@ stderr = unsafePerformIO (do
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
openFile
Ex
f m = do
ptr <- _ccall_ openFile f m'
if ptr /= ``NULL'' then do
#ifndef __PARALLEL_HASKELL__
...
...
@@ -208,13 +216,22 @@ openFile f m = do
_ -> 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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment