Hello community, here is the log from the commit of package ghc-memory for openSUSE:Factory checked in at 2016-05-31 12:24:26 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-memory (Old) and /work/SRC/openSUSE:Factory/.ghc-memory.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-memory" Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-memory/ghc-memory.changes 2016-01-28 17:24:53.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.ghc-memory.new/ghc-memory.changes 2016-05-31 12:24:27.000000000 +0200 @@ -1,0 +2,11 @@ +Mon May 23 10:48:17 UTC 2016 - [email protected] + +- update to 0.13 + +------------------------------------------------------------------- +Sun Apr 10 18:58:54 UTC 2016 - [email protected] + +- update to 0.12 +* Fix compilation with mkWeak and latest GHC + +------------------------------------------------------------------- Old: ---- memory-0.11.tar.gz New: ---- memory-0.13.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-memory.spec ++++++ --- /var/tmp/diff_new_pack.a46RLI/_old 2016-05-31 12:24:28.000000000 +0200 +++ /var/tmp/diff_new_pack.a46RLI/_new 2016-05-31 12:24:28.000000000 +0200 @@ -21,7 +21,7 @@ %bcond_with tests Name: ghc-memory -Version: 0.11 +Version: 0.13 Release: 0 Summary: Memory and related abtraction stuff License: BSD-3-Clause ++++++ memory-0.11.tar.gz -> memory-0.13.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/memory-0.11/CHANGELOG.md new/memory-0.13/CHANGELOG.md --- old/memory-0.11/CHANGELOG.md 2016-01-12 23:28:28.000000000 +0100 +++ new/memory-0.13/CHANGELOG.md 2016-05-22 10:29:35.000000000 +0200 @@ -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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/memory-0.11/Data/ByteArray/Mapping.hs new/memory-0.13/Data/ByteArray/Mapping.hs --- old/memory-0.11/Data/ByteArray/Mapping.hs 2016-01-12 23:28:28.000000000 +0100 +++ new/memory-0.13/Data/ByteArray/Mapping.hs 2016-05-22 10:29:35.000000000 +0200 @@ -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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/memory-0.11/Data/ByteArray/Pack.hs new/memory-0.13/Data/ByteArray/Pack.hs --- old/memory-0.11/Data/ByteArray/Pack.hs 2016-01-12 23:28:28.000000000 +0100 +++ new/memory-0.13/Data/ByteArray/Pack.hs 2016-05-22 10:29:35.000000000 +0200 @@ -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 equivalent to: -- --- it is basically: -- > 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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/memory-0.11/Data/ByteArray/Parse.hs new/memory-0.13/Data/ByteArray/Parse.hs --- old/memory-0.11/Data/ByteArray/Parse.hs 2016-01-12 23:28:28.000000000 +0100 +++ new/memory-0.13/Data/ByteArray/Parse.hs 2016-05-22 10:29:35.000000000 +0200 @@ -22,6 +22,7 @@ , parse , parseFeed -- * Parser methods + , hasMore , byte , anyByte , bytes @@ -55,7 +56,7 @@ -- * success: the remaining unparsed data and the parser value data Result byteArray a = ParseFail String - | ParseMore (byteArray -> Result byteArray a) + | ParseMore (Maybe byteArray -> Result byteArray a) | ParseOK byteArray a instance (Show ba, Show a) => Show (Result ba a) where @@ -63,31 +64,37 @@ show (ParseMore _) = "ParseMore _" show (ParseOK b a) = "ParseOK " ++ show a ++ " " ++ show b +-- | The continuation of the current buffer, and the error string type Failure byteArray r = byteArray -> String -> Result byteArray r + +-- | The continuation of the next buffer value, and the parsed value type Success byteArray a r = byteArray -> a -> Result byteArray r -- | Simple ByteString parser structure newtype Parser byteArray a = Parser - { runParser :: forall r . byteArray -> Failure byteArray r -> Success byteArray a r -> Result byteArray r } + { runParser :: forall r . byteArray + -> Failure byteArray r + -> Success byteArray a r + -> Result byteArray r } -instance Monad (Parser byteArray) where - fail errorMsg = Parser $ \buf err _ -> err buf ("failed: " ++ errorMsg) - return v = Parser $ \buf _ ok -> ok buf v - m >>= k = Parser $ \buf err ok -> - runParser m buf err (\buf' a -> runParser (k a) buf' err ok) -instance MonadPlus (Parser byteArray) where - mzero = fail "Parser.MonadPlus.mzero" - mplus f g = Parser $ \buf err ok -> - -- rewrite the err callback of @f to call @g - runParser f buf (\_ _ -> runParser g buf err ok) ok instance Functor (Parser byteArray) where fmap f p = Parser $ \buf err ok -> runParser p buf err (\b a -> ok b (f a)) instance Applicative (Parser byteArray) where pure = return (<*>) d e = d >>= \b -> e >>= \a -> return (b a) +instance Monad (Parser byteArray) where + fail errorMsg = Parser $ \buf err _ -> err buf ("Parser failed: " ++ errorMsg) + return v = Parser $ \buf _ ok -> ok buf v + m >>= k = Parser $ \buf err ok -> + runParser m buf err (\buf' a -> runParser (k a) buf' err ok) +instance MonadPlus (Parser byteArray) where + mzero = fail "MonadPlus.mzero" + mplus f g = Parser $ \buf err ok -> + -- rewrite the err callback of @f to call @g + runParser f buf (\_ _ -> runParser g buf err ok) ok instance Alternative (Parser byteArray) where - empty = fail "Parser.Alternative.empty" + empty = fail "Alternative.empty" (<|>) = mplus -- | Run a parser on an @initial byteArray. @@ -95,7 +102,10 @@ -- If the Parser need more data than available, the @feeder function -- is automatically called and fed to the More continuation. parseFeed :: (ByteArrayAccess byteArray, Monad m) - => m byteArray -> Parser byteArray a -> byteArray -> m (Result byteArray a) + => m (Maybe byteArray) + -> Parser byteArray a + -> byteArray + -> m (Result byteArray a) parseFeed feeder p initial = loop $ parse p initial where loop (ParseMore k) = feeder >>= (loop . k) loop r = return r @@ -106,25 +116,47 @@ parse p s = runParser p s (\_ msg -> ParseFail msg) (\b a -> ParseOK b a) ------------------------------------------------------------ + +-- When needing more data, getMore append the next data +-- to the current buffer. if no further data, then +-- the err callback is called. getMore :: ByteArray byteArray => Parser byteArray () getMore = Parser $ \buf err ok -> ParseMore $ \nextChunk -> - if B.null nextChunk - then err buf "EOL: need more data" - else ok (B.append buf nextChunk) () + case nextChunk of + Nothing -> err buf "EOL: need more data" + Just nc + | B.null nc -> runParser getMore buf err ok + | otherwise -> ok (B.append buf nc) () +-- Only used by takeAll, which accumulate all the remaining data +-- until ParseMore is fed a Nothing value. +-- +-- getAll cannot fail. getAll :: ByteArray byteArray => Parser byteArray () getAll = Parser $ \buf err ok -> ParseMore $ \nextChunk -> - if B.null nextChunk - then ok buf () - else runParser getAll (B.append buf nextChunk) err ok + case nextChunk of + Nothing -> ok buf () + Just nc -> runParser getAll (B.append buf nc) err ok +-- Only used by skipAll, which flush all the remaining data +-- until ParseMore is fed a Nothing value. +-- +-- flushAll cannot fail. flushAll :: ByteArray byteArray => Parser byteArray () flushAll = Parser $ \buf err ok -> ParseMore $ \nextChunk -> - if B.null nextChunk - then ok buf () - else runParser getAll B.empty err ok + case nextChunk of + Nothing -> ok buf () + Just _ -> runParser flushAll B.empty err ok ------------------------------------------------------------ +hasMore :: ByteArray byteArray => Parser byteArray Bool +hasMore = Parser $ \buf err ok -> + if B.null buf + then ParseMore $ \nextChunk -> + case nextChunk of + Nothing -> ok buf False + Just nc -> runParser hasMore nc err ok + else ok buf True -- | Get the next byte from the parser anyByte :: ByteArray byteArray => Parser byteArray Word8 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/memory-0.11/Data/ByteArray/ScrubbedBytes.hs new/memory-0.13/Data/ByteArray/ScrubbedBytes.hs --- old/memory-0.11/Data/ByteArray/ScrubbedBytes.hs 2016-01-12 23:28:28.000000000 +0100 +++ new/memory-0.13/Data/ByteArray/ScrubbedBytes.hs 2016-05-22 10:29:35.000000000 +0200 @@ -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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/memory-0.11/memory.cabal new/memory-0.13/memory.cabal --- old/memory-0.11/memory.cabal 2016-01-12 23:28:28.000000000 +0100 +++ new/memory-0.13/memory.cabal 2016-05-22 10:29:35.000000000 +0200 @@ -1,5 +1,5 @@ Name: memory -Version: 0.11 +Version: 0.13 Synopsis: memory and related abstraction stuff Description: Chunk of memory, polymorphic byte array management and manipulation
