Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion System/Random.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand All @@ -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.
Expand Down