packages feed

memory 0.11 → 0.12

raw patch · 5 files changed

+41/−18 lines, 5 filesdep ~base

Dependency ranges changed: base

Files

CHANGELOG.md view
@@ -1,3 +1,11 @@+## 0.12++* Fix compilation with mkWeak and latest GHC (Lars Kuhtz)++## 0.11++* add support for GHC 8.0.1+ ## 0.10  * make memConstEqual more constant not using boolean comparaison
Data/ByteArray/Mapping.hs view
@@ -8,10 +8,12 @@ module Data.ByteArray.Mapping     ( toW64BE     , toW64LE+    , fromW64BE     , mapAsWord64     , mapAsWord128     ) where +import           Data.Bits (shiftR) import           Data.ByteArray.Types import           Data.ByteArray.Methods import           Data.Memory.Internal.Compat@@ -37,8 +39,12 @@ toW64LE :: ByteArrayAccess bs => bs -> Int -> LE Word64 toW64LE bs ofs = unsafeDoIO $ withByteArray bs $ \p -> peek (p `plusPtr` ofs) +-- | Serialize a @Word64@ to a @ByteArray@ in big endian format+fromW64BE :: (ByteArray ba) => Word64 -> ba+fromW64BE n = allocAndFreeze 8 $ \p -> poke p (toBE n)+ -- | map blocks of 128 bits of a bytearray, creating a new bytestring--- of equivalent size where each blocks has been mapped through @f +-- of equivalent size where each blocks has been mapped through @f@ -- -- no length checking is done. unsafe mapAsWord128 :: ByteArray bs => (Word128 -> Word128) -> bs -> bs@@ -59,7 +65,7 @@             loop (i-1) (d `plusPtr` 16) (s `plusPtr` 16)  -- | map blocks of 64 bits of a bytearray, creating a new bytestring--- of equivalent size where each blocks has been mapped through @f +-- of equivalent size where each blocks has been mapped through @f@ -- -- no length checking is done. unsafe mapAsWord64 :: ByteArray bs => (Word64 -> Word64) -> bs -> bs
Data/ByteArray/Pack.hs view
@@ -45,7 +45,7 @@ import           Data.ByteArray (ByteArray, ByteArrayAccess, MemView(..)) import qualified Data.ByteArray as B --- | fill a given sized buffer with the result of the Packer action+-- | Fill a given sized buffer with the result of the Packer action fill :: ByteArray byteArray => Int -> Packer a -> Either String byteArray fill len packing = unsafeDoIO $ do     (val, out) <- B.allocRet len $ \ptr -> runPacker_ packing (MemView ptr len)@@ -55,7 +55,7 @@             | otherwise -> return $ Left ("remaining unpacked bytes " ++ show r ++ " at the end of buffer")         PackerFail err  -> return $ Left err --- | pack the given packer into the given bytestring+-- | Pack the given packer into the given bytestring pack :: ByteArray byteArray => Packer a -> Int -> Either String byteArray pack packing len = fill len packing {-# DEPRECATED pack "use fill instead" #-}@@ -65,11 +65,11 @@     memSet ptr w size     return $ PackerMore () (MemView (ptr `plusPtr` size) 0) --- | put a storable from the current position in the stream+-- | Put a storable from the current position in the stream putStorable :: Storable storable => storable -> Packer () putStorable s = actionPacker (sizeOf s) (\ptr -> poke (castPtr ptr) s) --- | put a Byte Array from the current position in the stream+-- | Put a Byte Array from the current position in the stream -- -- If the ByteArray is null, then do nothing putBytes :: ByteArrayAccess ba => ba -> Packer ()@@ -81,18 +81,20 @@   where     neededLength = B.length bs --- | skip some bytes from the current position in the stream+-- | Skip some bytes from the current position in the stream skip :: Int -> Packer () skip n = actionPacker n (\_ -> return ()) --- | skip the size of a storable from the current position in the stream+-- | Skip the size of a storable from the current position in the stream skipStorable :: Storable storable => storable -> Packer () skipStorable = skip . sizeOf --- | fill up from the current position in the stream to the end+-- | Fill up from the current position in the stream to the end ----- it is basically:+-- It is equivalent to:+-- -- > fillUpWith s == fillList (repeat s)+-- fillUpWith :: Storable storable => storable -> Packer () fillUpWith s = fillList $ repeat s {-# RULES "fillUpWithWord8" forall s . fillUpWith s = fillUpWithWord8' s #-}@@ -104,12 +106,19 @@ -- This function will fail with not enough storage if the given storable can't -- be written (not enough space) ----- example:--- > pack (fillList $ [1..] :: Word8) 9    ==> "\1\2\3\4\5\6\7\8\9"--- > pack (fillList $ [1..] :: Word32) 4   ==> "\1\0\0\0"--- > pack (fillList $ [1..] :: Word32) 64  -- will work--- > pack (fillList $ [1..] :: Word32) 1   -- will fail (not enough space)--- > pack (fillList $ [1..] :: Word32) 131 -- will fail (not enough space)+-- Example:+--+-- > > pack (fillList $ [1..] :: Word8) 9+-- > "\1\2\3\4\5\6\7\8\9"+-- > > pack (fillList $ [1..] :: Word32) 4+-- > "\1\0\0\0"+-- > > pack (fillList $ [1..] :: Word32) 64+-- > .. <..succesful..>+-- > > pack (fillList $ [1..] :: Word32) 1+-- > .. <.. not enough space ..>+-- > > pack (fillList $ [1..] :: Word32) 131+-- > .. <.. not enough space ..>+-- fillList :: Storable storable => [storable] -> Packer () fillList []     = return () fillList (x:xs) = putStorable x >> fillList xs
Data/ByteArray/ScrubbedBytes.hs view
@@ -69,7 +69,7 @@                  in case mkWeak# mbarr () (finalize scrubber mba) s1 of                     (# s2, _ #) -> (# s2, mba #)   where-#if __GLASGOW_HASKELL__ > 800+#if __GLASGOW_HASKELL__ > 801     finalize :: (State# RealWorld -> State# RealWorld) -> ScrubbedBytes -> State# RealWorld -> State# RealWorld     finalize scrubber mba@(ScrubbedBytes _) = \s1 ->         case scrubber s1 of
memory.cabal view
@@ -1,5 +1,5 @@ Name:                memory-Version:             0.11+Version:             0.12 Synopsis:            memory and related abstraction stuff Description:     Chunk of memory, polymorphic byte array management and manipulation