[commit: packages/random] master: Support base < 4.6 / GHC 7.4. (e6a0a92)
git at git.haskell.org
git at git.haskell.org
Thu Mar 19 15:45:23 UTC 2015
Repository : ssh://git@git.haskell.org/random
On branch : master
Link : http://git.haskell.org/packages/random.git/commitdiff/e6a0a92594d4c90cebc5806febd01d1c5ab23b18
>---------------------------------------------------------------
commit e6a0a92594d4c90cebc5806febd01d1c5ab23b18
Author: Mikhail Glushenkov <mikhail.glushenkov at gmail.com>
Date: Sat Aug 23 20:55:31 2014 +0200
Support base < 4.6 / GHC 7.4.
Fixes #10.
>---------------------------------------------------------------
e6a0a92594d4c90cebc5806febd01d1c5ab23b18
System/Random.hs | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/System/Random.hs b/System/Random.hs
index 97e98a5..4efcad6 100644
--- a/System/Random.hs
+++ b/System/Random.hs
@@ -93,7 +93,11 @@ import Data.Ratio ( numerator, denominator )
#endif
import Data.Char ( isSpace, chr, ord )
import System.IO.Unsafe ( unsafePerformIO )
-import Data.IORef
+import Data.IORef ( IORef, atomicModifyIORef, newIORef, readIORef
+ , writeIORef )
+#if MIN_VERSION_base (4,6,0)
+import Data.IORef ( atomicModifyIORef' )
+#endif
import Numeric ( readDec )
#ifdef __GLASGOW_HASKELL__
@@ -105,6 +109,15 @@ build :: ((a -> [a] -> [a]) -> [a] -> [a]) -> [a]
build g = g (:) []
#endif
+#if !MIN_VERSION_base (4,6,0)
+atomicModifyIORef' :: IORef a -> (a -> (a,b)) -> IO b
+atomicModifyIORef' ref f = do
+ b <- atomicModifyIORef ref
+ (\x -> let (a, b) = f x
+ in (a, a `seq` b))
+ b `seq` return b
+#endif
+
-- The standard nhc98 implementation of Time.ClockTime does not match
-- the extended one expected in this module, so we lash-up a quick
-- replacement here.
More information about the ghc-commits
mailing list