PrimitiveArray 0.7.0.0 → 0.7.0.1
raw patch · 5 files changed
+56/−20 lines, 5 filesdep +cereal-vectordep ~cereal
Dependencies added: cereal-vector
Dependency ranges changed: cereal
Files
- Data/PrimitiveArray/Checked.hs +29/−0
- Data/PrimitiveArray/Dense.hs +1/−1
- Data/PrimitiveArray/Index/Subword.hs +2/−2
- PrimitiveArray.cabal +19/−17
- changelog.md +5/−0
+ Data/PrimitiveArray/Checked.hs view
@@ -0,0 +1,29 @@++-- | This module exports everything that @Data.PrimitiveArray@ exports, but+-- it will do some bounds-checking on certain operations.+--+-- Checked are: @(!)@++module Data.PrimitiveArray.Checked+ ( module Data.PrimitiveArray+ , (!)+ ) where++import qualified Data.Vector.Generic as VG++import Data.PrimitiveArray hiding ((!))++-- | Bounds-checked version of indexing.+--+-- First, we check via @inBounds@, second we check if the linear index is+-- outside of the allocated area.++--(!) :: PrimArrayOps arr sh elm => arr sh elm -> sh -> elm+(!) arr@(Unboxed l h v) idx+ | not (uncurry inBounds (bounds arr) idx) = error $ "(!) / inBounds: out of bounds! " ++ show (l,h,idx)+ | li < 0 || li >= len = error $ "(!) / linearIndex: out of bounds! " ++ show (l,h,li,len,idx)+ | otherwise = unsafeIndex arr idx+ where li = linearIndex l h idx+ len = VG.length v+{-# Inline (!) #-}+
Data/PrimitiveArray/Dense.hs view
@@ -24,7 +24,7 @@ import Data.Binary (Binary) import Data.Serialize (Serialize) import Data.Vector.Binary-import Data.Vector.Cereal+import Data.Vector.Serialize import Data.Vector.Generic.Mutable as GM hiding (length) import Data.Vector.Unboxed.Mutable (Unbox) import GHC.Generics (Generic)
Data/PrimitiveArray/Index/Subword.hs view
@@ -191,8 +191,8 @@ instance Arbitrary (Subword t) where arbitrary = do- a <- choose (0,100)- b <- choose (0,100)+ a <- choose (0,20)+ b <- choose (0,20) return $ Subword (min a b :. max a b) shrink (Subword (i:.j)) | i<j = [Subword (i:.j-1), Subword (i+1:.j)]
PrimitiveArray.cabal view
@@ -1,17 +1,17 @@ Name: PrimitiveArray-Version: 0.7.0.0+Version: 0.7.0.1 License: BSD3 License-file: LICENSE Maintainer: choener@bioinf.uni-leipzig.de-author: Christian Hoener zu Siederdissen, 2011-2015-copyright: Christian Hoener zu Siederdissen, 2011-2015+author: Christian Hoener zu Siederdissen, 2011-2016+copyright: Christian Hoener zu Siederdissen, 2011-2016 homepage: https://github.com/choener/PrimitiveArray bug-reports: https://github.com/choener/PrimitiveArray/issues Stability: Experimental Category: Data Build-type: Simple Cabal-version: >=1.10.0-tested-with: GHC == 7.8.4, GHC == 7.10.2+tested-with: GHC == 7.8.4, GHC == 7.10.3 Synopsis: Efficient multidimensional arrays Description: <http://www.bioinf.uni-leipzig.de/Software/gADP/ generalized Algebraic Dynamic Programming>@@ -43,6 +43,7 @@ Library Exposed-modules: Data.PrimitiveArray+ Data.PrimitiveArray.Checked Data.PrimitiveArray.Class Data.PrimitiveArray.Dense Data.PrimitiveArray.FillTables@@ -57,19 +58,20 @@ Data.PrimitiveArray.Index.Unit Data.PrimitiveArray.QuickCheck.Index.Set Data.PrimitiveArray.Vector.Compat- build-depends: base >= 4.7 && < 4.9- , aeson >= 0.8 && < 0.11- , binary >= 0.7 && < 0.8- , bits >= 0.4 && < 0.5- , cereal >= 0.4 && < 0.5- , deepseq >= 1.3 && < 1.5- , hashable >= 1.2 && < 1.3- , OrderedBits >= 0.0.0.3 && < 0.0.2.0- , primitive >= 0.5.4 && < 0.7- , QuickCheck >= 2.7 && < 2.9- , vector >= 0.10 && < 0.12- , vector-binary-instances >= 0.2 && < 0.3- , vector-th-unbox >= 0.2 && < 0.3+ build-depends: base >= 4.7 && < 4.9+ , aeson >= 0.8 && < 0.11+ , binary >= 0.7 && < 0.8+ , bits >= 0.4 && < 0.5+ , cereal >= 0.4 && < 0.6+ , cereal-vector >= 0.2 && < 0.3+ , deepseq >= 1.3 && < 1.5+ , hashable >= 1.2 && < 1.3+ , OrderedBits >= 0.0.0.3 && < 0.0.2.0+ , primitive >= 0.5.4 && < 0.7+ , QuickCheck >= 2.7 && < 2.9+ , vector >= 0.10 && < 0.12+ , vector-binary-instances >= 0.2 && < 0.3+ , vector-th-unbox >= 0.2 && < 0.3 default-extensions: BangPatterns , CPP , DefaultSignatures
changelog.md view
@@ -1,3 +1,8 @@+0.7.0.1+-------++- Data.PrimitiveArray.Checked to capture index out-of-bounds problems+ 0.7.0.0 -------