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
47e446c7
Commit
47e446c7
authored
26 years ago
by
sof
Browse files
Options
Downloads
Patches
Plain Diff
[project @ 1998-05-16 20:01:18 by sof]
unsafeInterleaveIO: handle I/O failure a little bit more gracefully
parent
37a28e59
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ghc/lib/std/PrelUnsafe.lhs
+26
-5
26 additions, 5 deletions
ghc/lib/std/PrelUnsafe.lhs
with
26 additions
and
5 deletions
ghc/lib/std/PrelUnsafe.lhs
+
26
−
5
View file @
47e446c7
...
...
@@ -5,7 +5,25 @@
\section[PrelUnsafe]{Module @PrelUnsafe@}
These functions have their own module because we definitely don't want
them to be inlined.
them to be inlined. The reason is that we may end up turning an action
into a constant when it is not:
new :: IORef Int
new =
let
foo = unsafePerformIO getNextValue
in
newIORef foo
If unsafePerformIO is inlined here, the application of getNextValue to the realWorld#
token might be floated out, leaving us with
foo' = getNextValue realWorld#
new :: IORef Int
new = newIORef foo'
which is not what we want.
\begin{code}
{-# OPTIONS -fno-implicit-prelude #-}
...
...
@@ -40,11 +58,15 @@ unsafePerformIO (IO m)
unsafeInterleaveIO :: IO a -> IO a
unsafeInterleaveIO (IO m) = IO ( \ s ->
let
IOok _ r = m s
res =
case m s of
IOok _ r -> r
IOfail _ e -> error ("unsafeInterleaveIO: I/O error: " ++ show e ++ "\n")
in
IOok s r)
IOok s res
)
{-# GENERATE_SPECS _trace a #-}
trace :: String -> a -> a
trace string expr
= unsafePerformIO (
...
...
@@ -55,4 +77,3 @@ trace string expr
where
sTDERR = (``stderr'' :: Addr)
\end{code}
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