packages feed

regional-pointers 0.6 → 0.6.0.1

raw patch · 11 files changed

+63/−29 lines, 11 filesdep ~basedep ~regions

Dependency ranges changed: base, regions

Files

Foreign/C/String/Region.hs view
@@ -8,7 +8,7 @@ ------------------------------------------------------------------------------- -- | -- Module      :  Foreign.C.String.Region--- Copyright   :  (c) 2010 Bas van Dijk+-- Copyright   :  (c) 2010-2011 Bas van Dijk -- License     :  BSD3 (see the file LICENSE) -- Maintainer  :  Bas van Dijk <v.dijk.bas@gmail.com> --@@ -53,7 +53,7 @@ -- from base: import Data.Bool                         ( Bool ) import Data.Int                          ( Int )-import Data.Char                         ( Char, String )+import Data.Char                         ( Char ) import Foreign.C.Types                   ( CChar, CWchar ) import qualified Foreign.C.String as FCS ( peekCString,     peekCStringLen                                          , newCString,      newCStringLen@@ -75,6 +75,12 @@ import Foreign.C.String                  ( CString,  CStringLen                                          , CWString, CWStringLen                                          )+#endif++#if MIN_VERSION_base(4,4,0)+import Data.String                       ( String )+#else+import Data.Char                         ( String ) #endif  -- from base-unicode-symbols:
Foreign/Marshal/Alloc/Region.hs view
@@ -8,7 +8,7 @@ ------------------------------------------------------------------------------- -- | -- Module      :  Foreign.Marshal.Alloc.Region--- Copyright   :  (c) 2010 Bas van Dijk+-- Copyright   :  (c) 2010-2011 Bas van Dijk -- License     :  BSD3 (see the file LICENSE) -- Maintainer  :  Bas van Dijk <v.dijk.bas@gmail.com> --
Foreign/Marshal/Array/Region.hs view
@@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- -- | -- Module      :  Foreign.Marshal.Array.Region--- Copyright   :  (c) 2010 Bas van Dijk+-- Copyright   :  (c) 2010-2011 Bas van Dijk -- License     :  BSD3 (see the file LICENSE) -- Maintainer  :  Bas van Dijk <v.dijk.bas@gmail.com> --
Foreign/Marshal/Utils/Region.hs view
@@ -9,7 +9,7 @@ ------------------------------------------------------------------------------- -- | -- Module      :  Foreign.Marshal.Utils.Region--- Copyright   :  (c) 2010 Bas van Dijk+-- Copyright   :  (c) 2010-2011 Bas van Dijk -- License     :  BSD3 (see the file LICENSE) -- Maintainer  :  Bas van Dijk <v.dijk.bas@gmail.com> --
Foreign/Ptr/Region.hs view
@@ -3,7 +3,7 @@ ------------------------------------------------------------------------------- -- | -- Module      :  Foreign.Ptr.Region--- Copyright   :  (c) 2010 Bas van Dijk+-- Copyright   :  (c) 2010-2011 Bas van Dijk -- License     :  BSD3 (see the file LICENSE) -- Maintainer  :  Bas van Dijk <v.dijk.bas@gmail.com> --
Foreign/Ptr/Region/Internal.hs view
@@ -8,7 +8,7 @@ ------------------------------------------------------------------------------- -- | -- Module      :  Foreign.Ptr.Region.Internal--- Copyright   :  (c) 2010 Bas van Dijk+-- Copyright   :  (c) 2010-2011 Bas van Dijk -- License     :  BSD3 (see the file LICENSE) -- Maintainer  :  Bas van Dijk <v.dijk.bas@gmail.com> --@@ -53,12 +53,17 @@ import Control.Arrow                     ( first ) import Data.Function                     ( ($), flip ) import Data.Int                          ( Int )-import Data.Char                         ( String ) import System.IO                         ( IO ) import Foreign.Ptr                       ( Ptr ) import qualified Foreign.Ptr as FP       ( nullPtr ) import Foreign.Marshal.Alloc             ( free ) +#if MIN_VERSION_base(4,4,0)+import Data.String                       ( String )+#else+import Data.Char                         ( String )+#endif+ #if __GLASGOW_HASKELL__ < 700 import Control.Monad                     ( (>>=), fail ) #endif@@ -77,21 +82,23 @@                                          , LocalRegion, Local                                          , Dup(dup)                                          )-import Control.Monad.Trans.Region.Unsafe ( unsafeStripLocal )+import Control.Monad.Trans.Region.Unsafe ( unsafeStripLocal+                                         , unsafeControlIO+                                         , unsafeLiftIOOp+                                         , unsafeLiftIOOp_+                                         )  -- from monad-control:-import Control.Monad.IO.Control          ( MonadControlIO, controlIO, liftIOOp )+import Control.Monad.IO.Control          ( MonadControlIO )  #if MIN_VERSION_base(4,3,0)-import Control.Exception.Control         ( mask_ )+import Control.Exception         ( mask_ ) #else-import Control.Exception.Control         ( block )--mask_ ∷ MonadControlIO m ⇒ m a → m a+import Control.Exception         ( block )+mask_ ∷ IO a → IO a mask_ = block #endif - -------------------------------------------------------------------------------- -- * Regional pointers --------------------------------------------------------------------------------@@ -123,7 +130,7 @@  wrapMalloc ∷ MonadControlIO pr            ⇒ IO (Ptr α) → RegionT s pr (RegionalPtr α (RegionT s pr))-wrapMalloc doMalloc = mask_ $ do+wrapMalloc doMalloc = unsafeLiftIOOp_ mask_ $ do                         ptr ← liftIO doMalloc                         unsafeRegionalPtr ptr (free ptr) @@ -164,14 +171,14 @@            ⇒ ((Ptr α → IO (RegionT s pr β)) → IO (RegionT s pr β))            → (∀ sl. LocalPtr α (LocalRegion sl s) → RegionT (Local s) pr β)            → RegionT s pr β-wrapAlloca doAlloca f = liftIOOp doAlloca $+wrapAlloca doAlloca f = unsafeLiftIOOp doAlloca $                           unsafeStripLocal ∘ f ∘ LocalPtr  wrapAlloca2 ∷ MonadControlIO pr             ⇒ ((γ → Ptr α → IO (RegionT s pr β)) → IO (RegionT s pr β))             → (∀ sl. γ → LocalPtr α (LocalRegion sl s) → RegionT (Local s) pr β)             → RegionT s pr β-wrapAlloca2 doAlloca f = controlIO $ \runInIO →+wrapAlloca2 doAlloca f = unsafeControlIO $ \runInIO →                            doAlloca $ \s →                              runInIO ∘ unsafeStripLocal ∘ f s ∘ LocalPtr @@ -188,7 +195,7 @@ wrapNewStringLen ∷ MonadControlIO pr                  ⇒ IO (Ptr α, Int)                  → RegionT s pr (RegionalPtr α (RegionT s pr), Int)-wrapNewStringLen newStringLen = mask_ $ do+wrapNewStringLen newStringLen = unsafeLiftIOOp_ mask_ $ do                                   (ptr, len) ← liftIO newStringLen                                   rPtr ← unsafeRegionalPtr ptr (free ptr)                                   return (rPtr, len)@@ -197,7 +204,7 @@                   ⇒ (((Ptr α, Int) → IO (RegionT s pr β)) → IO (RegionT s pr β))                   → (∀ sl. (LocalPtr α (LocalRegion sl s), Int) → RegionT (Local s) pr β)                   → RegionT s pr β-wrapWithStringLen withStringLen f = liftIOOp withStringLen $+wrapWithStringLen withStringLen f = unsafeLiftIOOp withStringLen $                                       unsafeStripLocal ∘ f ∘ first LocalPtr  
Foreign/Ptr/Region/Unsafe.hs view
@@ -3,7 +3,7 @@ ------------------------------------------------------------------------------- -- | -- Module      :  Foreign.Ptr.Region.Unsfe--- Copyright   :  (c) 2010 Bas van Dijk+-- Copyright   :  (c) 2010-2011 Bas van Dijk -- License     :  BSD3 (see the file LICENSE) -- Maintainer  :  Bas van Dijk <v.dijk.bas@gmail.com> --
Foreign/Storable/Region.hs view
@@ -3,7 +3,7 @@ ------------------------------------------------------------------------------- -- | -- Module      :  Foreign.Storable.Region--- Copyright   :  (c) 2010 Bas van Dijk+-- Copyright   :  (c) 2010-2011 Bas van Dijk -- License     :  BSD3 (see the file LICENSE) -- Maintainer  :  Bas van Dijk <v.dijk.bas@gmail.com> --
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2010 Bas van Dijk+Copyright (c) 2010-2011 Bas van Dijk  All rights reserved. 
+ README.markdown view
@@ -0,0 +1,17 @@+The library allows you to allocate memory in a region yielding a regional+pointer to it. When the region terminates all pointers are automatically+freed. Most importantly, a pointer can't be returned from the region. So it's+impossible to reference unallocated memory.++The primary technique used in this package is called "Lightweight monadic+regions" which was [invented][1] by Oleg Kiselyov and Chung-chieh Shan.++This technique is implemented in the [regions] package which is re-exported from+this library.++This library provides wrappers around all the `Ptr` functions from the+[`Foreign.*`][foreign] modules of the `base` library.++[1]: http://okmij.org/ftp/Haskell/regions.html#light-weight+[regions]:  http://hackage.haskell.org/package/regions+[foreign]: http://hackage.haskell.org/packages/archive/base/latest/doc/html/Foreign.html
regional-pointers.cabal view
@@ -1,12 +1,14 @@ name:          regional-pointers-version:       0.6+version:       0.6.0.1 cabal-version: >=1.6 build-type:    Custom license:       BSD3 license-file:  LICENSE-copyright:     2010 Bas van Dijk+copyright:     2010-2011 Bas van Dijk author:        Bas van Dijk maintainer:    Bas van Dijk <v.dijk.bas@gmail.com>+homepage:      https://github.com/basvandijk/regional-pointers/+bug-reports:   https://github.com/basvandijk/regional-pointers/issues stability:     experimental category:      System, Monadic Regions synopsis:      Regional memory pointers@@ -28,15 +30,17 @@                This library provides wrappers around all the @Ptr@ functions                from the @Foreign.*@ modules of the @base@ library. +extra-source-files: README.markdown+ source-repository head-  Type:     darcs-  Location: http://code.haskell.org/~basvandijk/code/regional-pointers+  Type:     git+  Location: git://github.com/basvandijk/regional-pointers.git  Library   GHC-Options: -Wall-  build-depends: base                 >= 4     && < 4.4+  build-depends: base                 >= 4     && < 4.5                , base-unicode-symbols >= 0.1.1 && < 0.3-               , regions              >= 0.9   && < 0.10+               , regions              >= 0.10  && < 0.11                , transformers         >= 0.2   && < 0.3                , monad-control        >= 0.2   && < 0.3   exposed-modules: Foreign.Ptr.Region