packages feed

primitive 0.5.2.1 → 0.5.3.0

raw patch · 4 files changed

+98/−44 lines, 4 filesnew-uploader

Files

Data/Primitive/Array.hs view
@@ -16,7 +16,8 @@    newArray, readArray, writeArray, indexArray, indexArrayM,   unsafeFreezeArray, unsafeThawArray, sameMutableArray,-  copyArray, copyMutableArray+  copyArray, copyMutableArray,+  cloneArray, cloneMutableArray ) where  import Control.Monad.Primitive@@ -28,6 +29,8 @@ import Data.Data ( Data(..) ) import Data.Primitive.Internal.Compat ( isTrue#, mkNoRepType ) +import Control.Monad.ST(runST)+ -- | Boxed arrays data Array a = Array (Array# a) deriving ( Typeable ) @@ -154,6 +157,49 @@                        writeArray dst (doff+i) x                        go (i+1)          | otherwise = return ()+#endif++-- | Return a newly allocated Array with the specified subrange of the+-- provided Array. The provided Array should contain the full subrange+-- specified by the two Ints, but this is not checked.+cloneArray :: Array a -- ^ source array+           -> Int     -- ^ offset into destination array+           -> Int     -- ^ number of elements to copy+           -> Array a+{-# INLINE cloneArray #-}+#if __GLASGOW_HASKELL__ >= 702+cloneArray (Array arr#) (I# off#) (I# len#) +  = case cloneArray# arr# off# len# of arr'# -> Array arr'#+#else+cloneArray arr off len = runST $ do+    marr2 <- newArray len (error "Undefined element")+    copyArray marr2 0 arr off len+    unsafeFreezeArray marr2+#endif++-- | Return a newly allocated MutableArray. with the specified subrange of+-- the provided MutableArray. The provided MutableArray should contain the+-- full subrange specified by the two Ints, but this is not checked.+cloneMutableArray :: PrimMonad m+        => MutableArray (PrimState m) a -- ^ source array+        -> Int                          -- ^ offset into destination array+        -> Int                          -- ^ number of elements to copy+        -> m (MutableArray (PrimState m) a)+{-# INLINE cloneMutableArray #-}+#if __GLASGOW_HASKELL__ >= 702+cloneMutableArray (MutableArray arr#) (I# off#) (I# len#) = primitive+   (\s# -> case cloneMutableArray# arr# off# len# s# of+             (# s'#, arr'# #) -> (# s'#, MutableArray arr'# #))+#else+cloneMutableArray marr off len = do+        marr2 <- newArray len (error "Undefined element")+        let go !i !j c+                | c >= len = return marr2+                | otherwise = do+                    b <- readArray marr i+                    writeArray marr2 j b+                    go (i+1) (j+1) (c+1)+        go off 0 0 #endif  instance Typeable a => Data (Array a) where
− changelog
@@ -1,41 +0,0 @@-Changes in version 0.5.2.0-- * Add strict variants of 'MutVar' modification functions--Changes in version 0.5.1.0-- * Add support for GHC 7.7's new primitive 'Bool' representation--Changes in version 0.5.0.1-- * Disable array copying primitives for GHC 7.6.* and earlier--Changes in version 0.5-- * New in "Data.Primitive.MutVar": 'atomicModifyMutVar'-- * Efficient block fill operations: 'setByteArray', 'setAddr'--Changes in version 0.4.1-- * New module "Data.Primitive.MutVar"--Changes in version 0.4.0.1-- * Critical bug fix in 'fillByteArray'--Changes in version 0.4-- * Support for GHC 7.2 array copying primitives-- * New in "Data.Primitive.ByteArray": 'copyByteArray',-   'copyMutableByteArray', 'moveByteArray', 'fillByteArray'-- * Deprecated in "Data.Primitive.ByteArray": 'memcpyByteArray',-   'memcpyByteArray'', 'memmoveByteArray', 'memsetByteArray'-- * New in "Data.Primitive.Array": 'copyArray', 'copyMutableByteArray'-- * New in "Data.Primitive.Addr": 'copyAddr', 'moveAddr'-- * Deprecated in "Data.Primitive.Addr": 'memcpyAddr'
+ changelog.md view
@@ -0,0 +1,49 @@+## Changes in version 0.5.3.0++ * Implement `cloneArray` and `cloneMutableArray` primitives+   (with fall-back implementations for GHCs prior to version 7.2.1)++## Changes in version 0.5.2.1++ * Add strict variants of `MutVar` modification functions+   `atomicModifyMutVar'` and `modifyMutVar'`++ * Fix compilation on Solaris 10 with GNU C 3.4.3++## Changes in version 0.5.1.0++ * Add support for GHC 7.7's new primitive `Bool` representation++## Changes in version 0.5.0.1++ * Disable array copying primitives for GHC 7.6.* and earlier++## Changes in version 0.5++ * New in `Data.Primitive.MutVar`: `atomicModifyMutVar`++ * Efficient block fill operations: `setByteArray`, `setAddr`++## Changes in version 0.4.1++ * New module `Data.Primitive.MutVar`++## Changes in version 0.4.0.1++ * Critical bug fix in `fillByteArray`++## Changes in version 0.4++ * Support for GHC 7.2 array copying primitives++ * New in `Data.Primitive.ByteArray`: `copyByteArray`,+   `copyMutableByteArray`, `moveByteArray`, `fillByteArray`++ * Deprecated in `Data.Primitive.ByteArray`: `memcpyByteArray`,+   `memcpyByteArray'`, `memmoveByteArray`, `memsetByteArray`++ * New in `Data.Primitive.Array`: `copyArray`, `copyMutableByteArray`++ * New in `Data.Primitive.Addr`: `copyAddr`, `moveAddr`++ * Deprecated in `Data.Primitive.Addr`: `memcpyAddr`
primitive.cabal view
@@ -1,5 +1,5 @@ Name:           primitive-Version:        0.5.2.1+Version:        0.5.3.0 License:        BSD3 License-File:   LICENSE @@ -14,7 +14,7 @@ Build-Type:     Simple Description:    This package provides various primitive memory-related operations. -Extra-Source-Files: changelog+Extra-Source-Files: changelog.md  Library   Default-Language: Haskell2010