ref: 4c94735e4901cf9ce6784f903f844486c7a215a3
parent: 915858ede2f72c0da869397c78a7cc6f5912b3fb
parent: bcb571d56500ce09f9994d7ae777e830c9a6e629
author: James Hobson <j.w.hobson@icloud.com>
date: Sun Apr 7 13:51:57 EDT 2024
Merge branch 'augustss:master' into master
--- a/lib/Control/Exception.hs
+++ b/lib/Control/Exception.hs
@@ -77,17 +77,17 @@
unsafePerformIO (catch (evaluate v)
(\x -> throwIO (f x)))
--- XXX This isn't right. It should return an IO action.
+-- Evaluate a when executed, not when evaluated
evaluate :: a -> IO a
-evaluate a = seq a (return a)
+evaluate a = seq a (return ()) >> return a
-
try :: forall a e . Exception e => IO a -> IO (Either e a)
try ioa = catch (fmap Right ioa) (return . Left)
--- XXX This isn't right. It should return an IO action.
+-- Throw an exception when executed, not when evaluated
throwIO :: forall a e . Exception e => e -> IO a
-throwIO e = throw e
+throwIO e = bad >> bad -- we never reacj the second 'bad'
+ where bad = throw e
onException :: IO a -> IO b -> IO a
onException io what =
--- a/lib/Control/Exception/Internal.hs
+++ b/lib/Control/Exception/Internal.hs
@@ -4,8 +4,8 @@
throw, catch,
Exception(..),
SomeException(..),
- PatternMatchFail, NoMethodError, RecSelError, RecConError,
- patternMatchFail, NoMethodError, RecSelError, RecConError,
+ PatternMatchFail, NoMethodError, RecSelError, RecConError(..),
+ patternMatchFail, noMethodError, recSelError, recConError,
) where
import Prelude()
import Primitives(IO)
--- a/lib/System/IO.hs
+++ b/lib/System/IO.hs
@@ -17,7 +17,7 @@
interact,
writeFile, readFile, appendFile,
- cprint,
+ cprint, cuprint,
mkTextEncoding, hSetEncoding, utf8,
--- a/tests/ForeignPtr.hs
+++ b/tests/ForeignPtr.hs
@@ -9,18 +9,21 @@
add :: Ptr a -> Int -> Ptr a
add = plusPtr
+sInt :: Int
+sInt = sizeOf (0::Int)
+
main :: IO ()
main = do
fp <- mallocForeignPtrArray 2
withForeignPtr fp $ \ p -> do
poke p (42::Int)
- poke (add p 8) (88::Int)
+ poke (add p sInt) (88::Int)
withForeignPtr fp $ \ p -> do
gc
peek p >>= print
- peek (add p 8) >>= print
+ peek (add p sInt) >>= print
let fp1 :: ForeignPtr Int
- fp1 = plusForeignPtr fp 8
+ fp1 = plusForeignPtr fp sInt
withForeignPtr fp1 $ \ p -> do
peek p >>= print
gc
--
⑨