packages feed

contiguous-checked 0.3.0.0 → 0.3.2.0

raw patch · 3 files changed

+32/−4 lines, 3 filesdep ~contiguousPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: contiguous

API changes (from Hackage documentation)

+ Data.Primitive.Contiguous: append :: (Contiguous arr, Element arr a) => arr a -> arr a -> arr a
+ Data.Primitive.Contiguous: doubleton :: (Contiguous arr, Element arr a) => a -> a -> arr a
+ Data.Primitive.Contiguous: imap :: (Contiguous arr1, Element arr1 b, Contiguous arr2, Element arr2 c) => (Int -> b -> c) -> arr1 b -> arr2 c
+ Data.Primitive.Contiguous: imapMutable' :: (PrimMonad m, Contiguous arr, Element arr a) => (Int -> a -> a) -> Mutable arr (PrimState m) a -> m ()
+ Data.Primitive.Contiguous: map' :: (Contiguous arr1, Element arr1 b, Contiguous arr2, Element arr2 c) => (b -> c) -> arr1 b -> arr2 c
+ Data.Primitive.Contiguous: singleton :: (Contiguous arr, Element arr a) => a -> arr a
+ Data.Primitive.Contiguous: thaw :: (HasCallStack, Contiguous arr, PrimMonad m, Element arr b) => arr b -> Int -> Int -> m (Mutable arr (PrimState m) b)
+ Data.Primitive.Contiguous: traverse :: (Contiguous arr, Element arr a, Element arr b, Applicative f) => (a -> f b) -> arr a -> f (arr b)
+ Data.Primitive.Contiguous: traverseP :: (PrimMonad m, Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b) => (a -> m b) -> arr1 a -> m (arr2 b)
+ Data.Primitive.Contiguous: tripleton :: (Contiguous arr, Element arr a) => a -> a -> a -> arr a
+ Data.Primitive.Contiguous: type family Mutable (arr :: Type -> Type) = (r :: Type -> Type -> Type) | r -> arr
- Data.Primitive.Contiguous: foldMap :: (Contiguous arr, Element arr a, Monoid m) => a -> m -> arr a -> m
+ Data.Primitive.Contiguous: foldMap :: (Contiguous arr, Element arr a, Monoid m) => (a -> m) -> arr a -> m
- Data.Primitive.Contiguous: foldMap' :: (Contiguous arr, Element arr a, Monoid m) => a -> m -> arr a -> m
+ Data.Primitive.Contiguous: foldMap' :: (Contiguous arr, Element arr a, Monoid m) => (a -> m) -> arr a -> m
- Data.Primitive.Contiguous: foldl' :: (Contiguous arr, Element arr a) => b -> a -> b -> b -> arr a -> b
+ Data.Primitive.Contiguous: foldl' :: (Contiguous arr, Element arr a) => (b -> a -> b) -> b -> arr a -> b
- Data.Primitive.Contiguous: foldlM' :: (Contiguous arr, Element arr a, Monad m) => b -> a -> m b -> b -> arr a -> m b
+ Data.Primitive.Contiguous: foldlM' :: (Contiguous arr, Element arr a, Monad m) => (b -> a -> m b) -> b -> arr a -> m b
- Data.Primitive.Contiguous: foldr :: (Contiguous arr, Element arr a) => a -> b -> b -> b -> arr a -> b
+ Data.Primitive.Contiguous: foldr :: (Contiguous arr, Element arr a) => (a -> b -> b) -> b -> arr a -> b
- Data.Primitive.Contiguous: foldr' :: (Contiguous arr, Element arr a) => a -> b -> b -> b -> arr a -> b
+ Data.Primitive.Contiguous: foldr' :: (Contiguous arr, Element arr a) => (a -> b -> b) -> b -> arr a -> b
- Data.Primitive.Contiguous: itraverse_ :: (Contiguous arr, Element arr a, Applicative f) => Int -> a -> f b -> arr a -> f ()
+ Data.Primitive.Contiguous: itraverse_ :: (Contiguous arr, Element arr a, Applicative f) => (Int -> a -> f b) -> arr a -> f ()
- Data.Primitive.Contiguous: liftHashWithSalt :: (Contiguous arr, Element arr a) => Int -> a -> Int -> Int -> arr a -> Int
+ Data.Primitive.Contiguous: liftHashWithSalt :: (Contiguous arr, Element arr a) => (Int -> a -> Int) -> Int -> arr a -> Int
- Data.Primitive.Contiguous: map :: (Contiguous arr1, Element arr1 b, Contiguous arr2, Element arr2 c) => b -> c -> arr1 b -> arr2 c
+ Data.Primitive.Contiguous: map :: (Contiguous arr1, Element arr1 b, Contiguous arr2, Element arr2 c) => (b -> c) -> arr1 b -> arr2 c
- Data.Primitive.Contiguous: replicateM :: (Contiguous arr, PrimMonad m, Element arr b) => Int -> b -> m Mutable arr PrimState m b
+ Data.Primitive.Contiguous: replicateM :: (Contiguous arr, PrimMonad m, Element arr b) => Int -> b -> m (Mutable arr (PrimState m) b)
- Data.Primitive.Contiguous: sizeMutable :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr PrimState m b -> m Int
+ Data.Primitive.Contiguous: sizeMutable :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> m Int
- Data.Primitive.Contiguous: traverse_ :: (Contiguous arr, Element arr a, Applicative f) => a -> f b -> arr a -> f ()
+ Data.Primitive.Contiguous: traverse_ :: (Contiguous arr, Element arr a, Applicative f) => (a -> f b) -> arr a -> f ()
- Data.Primitive.Contiguous: unsafeFreeze :: (Contiguous arr, PrimMonad m) => Mutable arr PrimState m b -> m arr b
+ Data.Primitive.Contiguous: unsafeFreeze :: (Contiguous arr, PrimMonad m) => Mutable arr (PrimState m) b -> m (arr b)

Files

README.md view
@@ -1,1 +1,6 @@-# primitive-class+# contiguous-checked++A drop-in replacement for `contiguous` where all the functions+checks bounds at runtime. This is less efficient but gives+helpful error messages instead of segfaulting. It is intended+to be used when testing software.
contiguous-checked.cabal view
@@ -1,7 +1,12 @@ cabal-version: 2.0 name: contiguous-checked-version: 0.3.0.0-description: Please see the README on GitHub+version: 0.3.2.0+description:+  A drop-in replacement for `contiguous` where all the functions+  checks bounds at runtime. This is less efficient but gives+  helpful error messages instead of segfaulting. It is intended+  to be used when testing software.+synopsis: contiguous with bounds checks homepage: https://github.com/andrewthad/contiguous-checked bug-reports: https://github.com/andrewthad/contiguous-checked/issues author: Andrew Martin@@ -9,6 +14,7 @@ copyright: 2018 Andrew Martin license: BSD3 license-file: LICENSE+category: Data build-type: Simple extra-source-files: README.md @@ -23,6 +29,6 @@   build-depends:       base >=4.9 && <5     , primitive >= 0.6.4-    , contiguous >= 0.3 && < 0.4+    , contiguous >= 0.3.2 && < 0.4   default-language: Haskell2010 
src/Data/Primitive/Contiguous.hs view
@@ -35,19 +35,29 @@   , copyMutable   , clone   , cloneMutable+  , thaw   , C.equals   , C.unlift   , C.lift     -- * Synthetic Functions+  , C.singleton+  , C.doubleton+  , C.tripleton+  , C.append   , C.map+  , C.map'+  , C.imap   , C.foldr   , C.foldl'   , C.foldr'   , C.foldMap   , C.foldMap'   , C.foldlM'+  , C.traverse   , C.traverse_   , C.itraverse_+  , C.imapMutable'+  , C.traverseP   , unsafeFromListN   , unsafeFromListReverseN   , C.liftHashWithSalt@@ -75,6 +85,13 @@  new :: (HasCallStack, Contiguous arr, Element arr b, PrimMonad m) => Int -> m (Mutable arr (PrimState m) b) new n = check "new: negative size" (n>=0) (C.new n)++thaw :: (HasCallStack, Contiguous arr, PrimMonad m, Element arr b) => arr b -> Int -> Int -> m (Mutable arr (PrimState m) b)+thaw arr off len = check ("thaw: out of bounds [off=" ++ show off ++ ",len=" ++ show len ++ "]")+  (off >= 0 && len >= 0 && off + len <= sz)+  (C.thaw arr off len)+  where+  sz = C.size arr  index :: (HasCallStack, Contiguous arr, Element arr b) => arr b -> Int -> b index arr i = check ("index: out of bounds [ix=" ++ show i ++ ",sz=" ++ show sz ++ "]")