strict-io 0.2.1 → 0.2.2
raw patch · 5 files changed
+24/−23 lines, 5 filesdep ~basedep ~deepseq
Dependency ranges changed: base, deepseq
Files
- Data/IORef/Strict.hs +6/−5
- LICENSE +1/−1
- System/IO/Strict.hs +6/−6
- System/IO/Strict/Internals.hs +1/−1
- strict-io.cabal +10/−10
Data/IORef/Strict.hs view
@@ -1,7 +1,7 @@ -------------------------------------------------------------------- -- | -- Module : Data.IORef.Strict--- Copyright : (c) Nicolas Pouillard 2009+-- Copyright : (c) Nicolas Pouillard 2009-2017 -- License : BSD3 -- -- Maintainer : Nicolas Pouillard <nicolas.pouillard@gmail.com>@@ -30,7 +30,7 @@ import Data.IORef (IORef) import Control.DeepSeq (NFData(..)) --- | Build a new 'IORef', but force the value before storing it.+-- | Build a new 'IORef', but deeply force the value before storing it. newIORef :: NFData sa => sa -> SIO (IORef sa) newIORef value = rnf value `seq` SIO (IO.newIORef value) @@ -40,7 +40,7 @@ -- | Deeply force a value and write it into an 'IORef' writeIORef :: NFData sa => IORef sa -> sa -> SIO ()-writeIORef ref value = rnf value `seq` SIO $ IO.writeIORef ref value+writeIORef ref value = rnf value `seq` SIO (IO.writeIORef ref value) -- | Mutate the contents of an 'IORef' modifyIORef :: NFData sa => IORef sa -> (sa -> sa) -> SIO ()@@ -55,10 +55,11 @@ -- Extending the atomicity to multiple 'IORef's is problematic, so it is recommended that -- if you need to do anything more complicated then using "Control.Concurrent.MVar.MVar" -- instead is a good idea.+--+-- Internally this function is using @Data.IORef.atomicModifyIORef'@. atomicModifyIORef :: (NFData sa, NFData sb) => IORef sa -> (sa -> (sa, sb)) -> SIO sb-atomicModifyIORef ref f = SIO $ do x <- IO.atomicModifyIORef ref (rnf' . f)+atomicModifyIORef ref f = SIO $ do x <- IO.atomicModifyIORef' ref (rnf' . f) rnf x `seq` return x- -- since the result of 'f' is a pair which has to forced where rnf' x = rnf x `seq` x -- | Make a 'Weak' pointer to an 'IORef'
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2009, Nicolas Pouillard+Copyright (c) 2009-2017, Nicolas Pouillard All rights reserved. Redistribution and use in source and binary forms, with or without
System/IO/Strict.hs view
@@ -18,7 +18,7 @@ -- will not leak-out after the call. -- -- These functions do not necessarily use their arguments completely but they do not hold--- or return any value that could depend on these arguments. If the original functions +-- or return any value that could depend on these arguments. If the original functions -- from "System.IO" module were already strict, then this module just provides them -- at another type. -- Some functions from the original module are famously lazy like the 'getContents' like@@ -41,7 +41,7 @@ SIO, run, return',- + -- * Functions stricter than there "System.IO" counterparts getContents, -- :: SIO String hGetContents, -- :: Handle -> SIO String@@ -196,7 +196,7 @@ hGetLine :: Handle -> SIO String hGetLine = wrap1 IO.hGetLine hGetPosn :: Handle -> SIO HandlePosn-hGetPosn = wrap1 IO.hGetPosn +hGetPosn = wrap1 IO.hGetPosn hIsClosed :: Handle -> SIO Bool hIsClosed = wrap1 IO.hIsClosed hIsEOF :: Handle -> SIO Bool@@ -206,11 +206,11 @@ hIsReadable :: Handle -> SIO Bool hIsReadable = wrap1 IO.hIsReadable hIsSeekable :: Handle -> SIO Bool-hIsSeekable = wrap1 IO.hIsSeekable +hIsSeekable = wrap1 IO.hIsSeekable hIsTerminalDevice :: Handle -> SIO Bool hIsTerminalDevice = wrap1 IO.hIsTerminalDevice hIsWritable :: Handle -> SIO Bool-hIsWritable = wrap1 IO.hIsWritable +hIsWritable = wrap1 IO.hIsWritable hLookAhead :: Handle -> SIO Char hLookAhead = wrap1 IO.hLookAhead hPutBuf :: Handle -> Ptr a -> Int -> SIO ()@@ -232,7 +232,7 @@ hSetFileSize :: Handle -> Integer -> SIO () hSetFileSize = wrap2 IO.hSetFileSize hSetPosn :: HandlePosn -> SIO ()-hSetPosn = wrap1 IO.hSetPosn +hSetPosn = wrap1 IO.hSetPosn hShow :: Handle -> SIO String hShow = wrap1 IO.hShow hTell :: Handle -> SIO Integer
System/IO/Strict/Internals.hs view
@@ -24,7 +24,7 @@ -- * A stricter 'return' return',- + -- * Wrapping functions wrap0, -- :: IO a -> SIO a wrap0', -- :: NFData sa => IO sa -> SIO sa
strict-io.cabal view
@@ -1,6 +1,6 @@ name: strict-io cabal-Version: >=1.6-version: 0.2.1+version: 0.2.2 license: BSD3 license-File: LICENSE copyright: (c) Nicolas Pouillard@@ -8,24 +8,24 @@ maintainer: Nicolas Pouillard <nicolas.pouillard@gmail.com> category: System synopsis: A library wrapping standard IO modules to provide strict IO.-description: This library is a thin layer on top standard IO modules like System.IO- and Data.IORef that re-expose these functions under a different type, namely SIO.+description: A thin layer on top standard IO modules like System.IO+ and Data.IORef that re-expose strict functions using the SIO+ monad. stability: Provisional build-type: Simple library- build-depends: base>=3.0 && <5, deepseq>=1.1 && <1.4, extensible-exceptions+ build-depends: base>=4.6 && <5, deepseq>=1.1 && <1.5, extensible-exceptions exposed-modules: System.IO.Strict System.IO.Strict.Internals Data.IORef.Strict ghc-options: -Wall -O2 source-repository head- type: darcs- location: http://patch-tag.com/publicrepos/strict-io+ type: git+ location: https://github.com/np/strict-io source-repository this- type: darcs- location: http://patch-tag.com/publicrepos/strict-io- tag: 0.2.0-+ type: git+ location: https://github.com/np/strict-io+ tag: v0.2.2