packages feed

binary 0.8.7.0 → 0.10.0.0

raw patch · 9 files changed

Files

binary.cabal view
@@ -1,5 +1,5 @@ name:            binary-version:         0.8.7.0+version:         0.10.0.0 license:         BSD3 license-file:    LICENSE author:          Lennart Kolmodin <kolmodin@gmail.com>@@ -18,7 +18,7 @@ stability:       provisional build-type:      Simple cabal-version:   >= 1.8-tested-with:     GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC ==8.2.2, GHC == 8.4.4, GHC == 8.6.5+tested-with:     GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2 extra-source-files:   README.md changelog.md docs/hcar/binary-Lb.tex tools/derive/*.hs @@ -76,7 +76,6 @@     Data.Binary.Put   build-depends:     base >= 4.5.0.0 && < 5,-    base-orphans >=0.8.1 && <0.9,     bytestring >= 0.10.4,     random>=1.0.1.0,     test-framework,@@ -159,7 +158,6 @@     Data.Binary.Class     Data.Binary.FloatCast     Data.Binary.Generic-    Data.Binary.Get     Data.Binary.Get.Internal     Data.Binary.Internal     Data.Binary.Put@@ -192,7 +190,6 @@     Data.Binary.Get     Data.Binary.Get.Internal     Data.Binary.Internal-    Data.Binary.Put   build-depends:     base >= 4.5.0.0 && < 5,     bytestring >= 0.10.4,
changelog.md view
@@ -1,26 +1,19 @@ binary ====== -binary-0.8.7.0------------------ MonadFail compatibility in base-4.13 (`fail` is not method of `Monad).-- `Binary NonEmpty` `fail`s non empty lists, not `error`s--binary-0.9.0.0 & binary-0.10.0.0------------------------------------ `0.8.5.0` was first released as version `0.9.0.0`. It didn't have any-  breaking changes though, so it was again released as version `0.8.5.0`-  according to PVP.-- `0.8.6.0` was first released as version `0.10.0.0`.--binary-0.8.6.0+binary-0.10.0.0 ---------------  - Add binary instance for Data.Functor.Identity from base, #146. - Don't use * when we have TypeOperators, #148. +binary-0.9.0.0+--------------++- `0.8.5.0` was first released as version `0.9.0.0`. It didn't have any+  breaking changes though, so it was again released as version `0.8.5.0`+  according to PVP. Next breaking release of `binary` will be version+  `0.10.0.0`.  binary-0.8.5.0 --------------
src/Data/Binary.hs view
@@ -132,7 +132,7 @@ -- > > let e = OpE "*" (IntE 7) (OpE "/" (IntE 4) (IntE 2)) -- > > let v = encode e ----- Where @v@ is a binary encoded data structure. To reconstruct the+-- Where 'v' is a binary encoded data structure. To reconstruct the -- original data, we use 'decode' -- -- > > decode v :: Exp@@ -177,7 +177,7 @@ -- consumed bytes is returned. In case of failure, a human-readable error -- message will be returned as well. ----- @since 0.7.0.0+-- /Since: 0.7.0.0/ decodeOrFail :: Binary a => L.ByteString              -> Either (L.ByteString, ByteOffset, String)                        (L.ByteString, ByteOffset, a)@@ -203,7 +203,7 @@ -- | Decode a value from a file. In case of errors, 'error' will -- be called with the error message. ----- @since 0.7.0.0+-- /Since: 0.7.0.0/ decodeFile :: Binary a => FilePath -> IO a decodeFile f = do   result <- decodeFileOrFail f
src/Data/Binary/Class.hs view
@@ -59,9 +59,7 @@ import Data.Monoid (mempty) #endif import qualified Data.Monoid as Monoid-#if !MIN_VERSION_base(4,11,0) import Data.Monoid ((<>))-#endif #if MIN_VERSION_base(4,8,0) import Data.Functor.Identity (Identity (..)) #endif@@ -174,7 +172,7 @@ -- Void never gets written nor reconstructed since it's impossible to have a -- value of that type --- | @since 0.8.0.0+-- | /Since: 0.8.0.0/ instance Binary Void where     put     = absurd     get     = mzero@@ -339,7 +337,7 @@                     let v = roll bytes                     return $! if sign == (1 :: Word8) then v else - v --- | @since 0.8.0.0+-- | /Since: 0.8.0.0/ #ifdef HAS_FIXED_CONSTRUCTOR instance Binary (Fixed.Fixed a) where   put (Fixed.MkFixed a) = put a@@ -369,7 +367,7 @@ -- Fixed-size type for a subset of Natural type NaturalWord = Word64 --- | @since 0.7.3.0+-- | /Since: 0.7.3.0/ instance Binary Natural where     {-# INLINE put #-}     put n | n <= hi =@@ -582,7 +580,7 @@     get = do n <- get :: Get Int              getMany n --- | @'getMany' n@ get @n@ elements in order, without blowing the stack.+-- | 'getMany n' get 'n' elements in order, without blowing the stack. getMany :: Binary a => Int -> Get [a] getMany n = go [] n  where@@ -727,7 +725,7 @@ ------------------------------------------------------------------------ -- Fingerprints --- | @since 0.7.6.0+-- | /Since: 0.7.6.0/ instance Binary Fingerprint where     put (Fingerprint x1 x2) = put x1 <> put x2     get = do@@ -738,7 +736,7 @@ ------------------------------------------------------------------------ -- Version --- | @since 0.8.0.0+-- | /Since: 0.8.0.0/ instance Binary Version where     put (Version br tags) = put br <> put tags     get = Version <$> get <*> get@@ -746,43 +744,43 @@ ------------------------------------------------------------------------ -- Data.Monoid datatypes --- | @since 0.8.4.0+-- | /Since: 0.8.4.0/ instance Binary a => Binary (Monoid.Dual a) where   get = fmap Monoid.Dual get   put = put . Monoid.getDual --- | @since 0.8.4.0+-- | /Since: 0.8.4.0/ instance Binary Monoid.All where   get = fmap Monoid.All get   put = put . Monoid.getAll --- | @since 0.8.4.0+-- | /Since: 0.8.4.0/ instance Binary Monoid.Any where   get = fmap Monoid.Any get   put = put . Monoid.getAny --- | @since 0.8.4.0+-- | /Since: 0.8.4.0/ instance Binary a => Binary (Monoid.Sum a) where   get = fmap Monoid.Sum get   put = put . Monoid.getSum --- | @since 0.8.4.0+-- | /Since: 0.8.4.0/ instance Binary a => Binary (Monoid.Product a) where   get = fmap Monoid.Product get   put = put . Monoid.getProduct --- | @since 0.8.4.0+-- | /Since: 0.8.4.0/ instance Binary a => Binary (Monoid.First a) where   get = fmap Monoid.First get   put = put . Monoid.getFirst --- | @since 0.8.4.0+-- | /Since: 0.8.4.0/ instance Binary a => Binary (Monoid.Last a) where   get = fmap Monoid.Last get   put = put . Monoid.getLast  #if MIN_VERSION_base(4,8,0)--- | @since 0.8.4.0+-- | /Since: 0.8.4.0/ instance Binary (f a) => Binary (Monoid.Alt f a) where   get = fmap Monoid.Alt get   put = put . Monoid.getAlt@@ -792,37 +790,37 @@ ------------------------------------------------------------------------ -- Data.Semigroup datatypes --- | @since 0.8.4.0+-- | /Since: 0.8.4.0/ instance Binary a => Binary (Semigroup.Min a) where   get = fmap Semigroup.Min get   put = put . Semigroup.getMin --- | @since 0.8.4.0+-- | /Since: 0.8.4.0/ instance Binary a => Binary (Semigroup.Max a) where   get = fmap Semigroup.Max get   put = put . Semigroup.getMax --- | @since 0.8.4.0+-- | /Since: 0.8.4.0/ instance Binary a => Binary (Semigroup.First a) where   get = fmap Semigroup.First get   put = put . Semigroup.getFirst --- | @since 0.8.4.0+-- | /Since: 0.8.4.0/ instance Binary a => Binary (Semigroup.Last a) where   get = fmap Semigroup.Last get   put = put . Semigroup.getLast --- | @since 0.8.4.0+-- | /Since: 0.8.4.0/ instance Binary a => Binary (Semigroup.Option a) where   get = fmap Semigroup.Option get   put = put . Semigroup.getOption --- | @since 0.8.4.0+-- | /Since: 0.8.4.0/ instance Binary m => Binary (Semigroup.WrappedMonoid m) where   get = fmap Semigroup.WrapMonoid get   put = put . Semigroup.unwrapMonoid --- | @since 0.8.4.0+-- | /Since: 0.8.4.0/ instance (Binary a, Binary b) => Binary (Semigroup.Arg a b) where   get                     = liftM2 Semigroup.Arg get get   put (Semigroup.Arg a b) = put a <> put b@@ -830,13 +828,9 @@ ------------------------------------------------------------------------ -- Non-empty lists --- | @since 0.8.4.0+-- | /Since: 0.8.4.0/ instance Binary a => Binary (NE.NonEmpty a) where-  get = do-      list <- get-      case list of-        [] -> fail "NonEmpty is empty!"-        x:xs -> pure (x NE.:| xs)+  get = fmap NE.fromList get   put = put . NE.toList #endif @@ -864,17 +858,17 @@ -- * 'SomeTypeRep' (also known as 'Data.Typeable.TypeRep') -- --- | @since 0.8.5.0+-- | @since 0.8.5.0. See #typeable-instances# instance Binary VecCount where     put = putWord8 . fromIntegral . fromEnum     get = toEnum . fromIntegral <$> getWord8 --- | @since 0.8.5.0+-- | @since 0.8.5.0. See #typeable-instances# instance Binary VecElem where     put = putWord8 . fromIntegral . fromEnum     get = toEnum . fromIntegral <$> getWord8 --- | @since 0.8.5.0+-- | @since 0.8.5.0. See #typeable-instances# instance Binary RuntimeRep where     put (VecRep a b)    = putWord8 0 >> put a >> put b     put (TupleRep reps) = putWord8 1 >> put reps@@ -888,12 +882,6 @@     put AddrRep         = putWord8 9     put FloatRep        = putWord8 10     put DoubleRep       = putWord8 11-#if __GLASGOW_HASKELL__ >= 807-    put Int8Rep         = putWord8 12-    put Word8Rep        = putWord8 13-    put Int16Rep        = putWord8 14-    put Word16Rep       = putWord8 15-#endif      get = do         tag <- getWord8@@ -910,15 +898,9 @@           9  -> pure AddrRep           10 -> pure FloatRep           11 -> pure DoubleRep-#if __GLASGOW_HASKELL__ >= 807-          12 -> pure Int8Rep-          13 -> pure Word8Rep-          14 -> pure Int16Rep-          15 -> pure Word16Rep-#endif           _  -> fail "GHCi.TH.Binary.putRuntimeRep: invalid tag" --- | @since 0.8.5.0+-- | @since 0.8.5.0. See #typeable-instances# instance Binary TyCon where     put tc = do         put (tyConPackage tc)@@ -928,7 +910,7 @@         put (tyConKindRep tc)     get = mkTyCon <$> get <*> get <*> get <*> get <*> get --- | @since 0.8.5.0+-- | @since 0.8.5.0. See #typeable-instances# instance Binary KindRep where     put (KindRepTyConApp tc k) = putWord8 0 >> put tc >> put k     put (KindRepVar bndr) = putWord8 1 >> put bndr@@ -948,7 +930,7 @@           5 -> KindRepTypeLit <$> get <*> get           _ -> fail "GHCi.TH.Binary.putKindRep: invalid tag" --- | @since 0.8.5.0+-- | @since 0.8.5.0. See #typeable-instances# instance Binary TypeLitSort where     put TypeLitSymbol = putWord8 0     put TypeLitNat = putWord8 1@@ -978,7 +960,7 @@     put (3 :: Word8)     putTypeRep arg     putTypeRep res-putTypeRep _ = error "GHCi.TH.Binary.putTypeRep: Impossible"+putTypeRep _ = fail "GHCi.TH.Binary.putTypeRep: Impossible"  getSomeTypeRep :: Get SomeTypeRep getSomeTypeRep = do
src/Data/Binary/FloatCast.hs view
@@ -5,7 +5,7 @@ -- | This module was written based on --   <http://hackage.haskell.org/package/reinterpret-cast-0.1.0/docs/src/Data-ReinterpretCast-Internal-ImplArray.html>. -----   Implements casting via a 1-element STUArray, as described in+--   Implements casting via a 1-elemnt STUArray, as described in --   <http://stackoverflow.com/a/7002812/263061>. module Data.Binary.FloatCast   ( floatToWord
src/Data/Binary/Generic.hs view
@@ -30,9 +30,7 @@ import Data.Binary.Put import Data.Bits import Data.Word-#if !MIN_VERSION_base(4,11,0) import Data.Monoid ((<>))-#endif #ifdef HAS_DATA_KIND import Data.Kind #endif
src/Data/Binary/Get.hs view
@@ -126,7 +126,7 @@ -- from a socket which has higher likelihood to fail. To address these needs, -- use the incremental input method like in @incrementalExample@. -- For an example of how to read incrementally from a Handle,--- see the implementation of 'Data.Binary.decodeFileOrFail'.+-- see the implementation of 'decodeFileOrFail' in "Data.Binary". -----------------------------------------------------------------------------  @@ -328,7 +328,7 @@ -- consumed is returned. In the case of failure, a human-readable -- error message is included as well. ----- @since 0.6.4.0+-- /Since: 0.6.4.0/ runGetOrFail :: Get a -> L.ByteString              -> Either (L.ByteString, ByteOffset, String) (L.ByteString, ByteOffset, a) runGetOrFail g lbs0 = feedAll (runGetIncremental g) lbs0@@ -366,7 +366,7 @@   -- | Feed a 'Decoder' with more input. If the 'Decoder' is 'Done' or 'Fail' it--- will add the input to 'L.ByteString' of unconsumed input.+-- will add the input to 'ByteString' of unconsumed input. -- -- @ --    'runGetIncremental' myParser \`pushChunks\` myLazyByteString
src/Data/Binary/Get/Internal.hs view
@@ -91,20 +91,12 @@ instance Monad Get where   return = pure   (>>=) = bindG-#if !(MIN_VERSION_base(4,9,0))-  fail = failG -- base < 4.9-#elif !(MIN_VERSION_base(4,13,0))-  fail = Fail.fail -- base < 4.13-#endif--- NB: Starting with base-4.13, the `fail` method---     has been removed from the `Monad`-class---     according to the MonadFail proposal (MFP) schedule---     which completes the process that started with base-4.9.- #if MIN_VERSION_base(4,9,0)+  fail = Fail.fail+ instance Fail.MonadFail Get where-  fail = failG #endif+  fail = failG  bindG :: Get a -> (a -> Get b) -> Get b bindG (C c) f = C $ \i ks -> c i (\i' a -> (runCont (f a)) i' ks)@@ -130,7 +122,7 @@   (<*>) = apG   {-# INLINE (<*>) #-} --- | @since 0.7.1.0+-- | /Since: 0.7.1.0/ instance MonadPlus Get where   mzero = empty   mplus = (<|>)@@ -201,7 +193,7 @@ -- Offset from 'bytesRead' will be relative to the start of 'isolate', not the -- absolute of the input. ----- @since 0.7.2.0+-- /Since: 0.7.2.0/ isolate :: Int   -- ^ The number of bytes that must be consumed         -> Get a -- ^ The decoder to isolate         -> Get a@@ -264,7 +256,7 @@ getBytes = getByteString {-# INLINE getBytes #-} --- | @since 0.7.0.0+-- | /Since: 0.7.0.0/ instance Alternative Get where   empty = C $ \inp _ks -> Fail inp "Data.Binary.Get(Alternative).empty"   {-# INLINE empty #-}@@ -312,7 +304,7 @@ -- | Run the given decoder, but without consuming its input. If the given -- decoder fails, then so will this function. ----- @since 0.7.0.0+-- /Since: 0.7.0.0/ lookAhead :: Get a -> Get a lookAhead g = do   (decoder, bs) <- runAndKeepTrack g@@ -325,7 +317,7 @@ -- If 'Nothing' is returned, the input will be unconsumed. -- If the given decoder fails, then so will this function. ----- @since 0.7.0.0+-- /Since: 0.7.0.0/ lookAheadM :: Get (Maybe a) -> Get (Maybe a) lookAheadM g = do   let g' = maybe (Left ()) Right <$> g@@ -335,7 +327,7 @@ -- If 'Left' is returned, the input will be unconsumed. -- If the given decoder fails, then so will this function. ----- @since 0.7.1.0+-- /Since: 0.7.1.0/ lookAheadE :: Get (Either a b) -> Get (Either a b) lookAheadE g = do   (decoder, bs) <- runAndKeepTrack g@@ -348,7 +340,7 @@ -- | Label a decoder. If the decoder fails, the label will be appended on -- a new line to the error message string. ----- @since 0.7.2.0+-- /Since: 0.7.2.0/ label :: String -> Get a -> Get a label msg decoder = C $ \inp ks ->   let r0 = runCont decoder inp (\inp' a -> Done inp' a)
tests/QC.hs view
@@ -24,8 +24,6 @@ import           Data.Typeable import           System.IO.Unsafe -import           Data.Orphans ()- #ifdef HAS_NATURAL import           Numeric.Natural #endif@@ -45,7 +43,6 @@ import           Data.Binary.Put import qualified Data.Binary.Class as Class - ------------------------------------------------------------------------  roundTrip :: (Eq a, Binary a) => a -> (L.ByteString -> L.ByteString) -> Bool@@ -502,6 +499,10 @@  genFingerprint :: Gen Fingerprint genFingerprint = liftM2 Fingerprint arbitrary arbitrary+#if !MIN_VERSION_base(4,7,0)+instance Show Fingerprint where+  show (Fingerprint x1 x2) = show (x1,x2)+#endif  ------------------------------------------------------------------------