packages feed

bencoding 0.4.5.4 → 0.4.5.5

raw patch · 7 files changed

+32/−14 lines, 7 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

ChangeLog view
@@ -1,3 +1,7 @@+2024-01-01  Sergey Vinokurov  <serg.foo@gmail.com>++	* 0.4.5.5: Fix build for 9.6+ 2019-10-27  Sergey Vinokurov  <serg.foo@gmail.com>  	* 0.4.5.2: Fix build for 8.8.1
README.md view
@@ -38,7 +38,7 @@  ### Build Status -[![Build Status][travis-img]][travis-log]+[![build](https://github.com/sergv/bencoding/actions/workflows/ci.yaml/badge.svg)](https://github.com/sergv/bencoding/actions/workflows/ci.yaml)  ### Maintainer <serg.foo@gmail.com> @@ -52,9 +52,6 @@ [json-ref]: http://www.json.org/ [attoparsec]: http://hackage.haskell.org/package/attoparsec-0.10.4.0 [bytestring-builder]: http://hackage.haskell.org/packages/archive/bytestring/0.10.2.0/doc/html/Data-ByteString-Builder.html--[travis-img]: https://travis-ci.org/sergv/bencoding.svg?branch=master-[travis-log]: https://travis-ci.org/sergv/bencoding  [hackage]: http://hackage.haskell.org/package/bencoding [issues]: https://github.com/sergv/bencoding/issues
bench/Main.hs view
@@ -90,7 +90,7 @@   } deriving (Show, Eq, Typeable)  instance NFData Torrent where-  rnf Torrent {..} = ()+  rnf Torrent {} = ()  instance C.BEncode Torrent where   toBEncode Torrent {..} = toDict $
bencoding.cabal view
@@ -1,5 +1,5 @@ name:                  bencoding-version:               0.4.5.4+version:               0.4.5.5 license:               BSD3 license-file:          LICENSE author:                Sam Truzjan@@ -54,7 +54,7 @@                      , Data.BEncode.BDict                      , Data.BEncode.Internal                      , Data.BEncode.Types-  build-depends:       base       >= 4.4 && < 5+  build-depends:       base       >= 4.9 && < 5                      , ghc-prim                      , integer-gmp                      , deepseq    >= 1.3
src/Data/BEncode.hs view
@@ -668,19 +668,13 @@ --  \"length\" '<' \"md5sum\" '<' \"path\" '<' \"tags\" -- newtype Get a = Get { runGet :: StateT BDict Result a }-  deriving (Functor, Applicative, Alternative)+  deriving (Functor, Applicative)  -- | 'fail' is catchable from pure code. instance Monad Get where-  return a = Get (return a)-  {-# INLINE return #-}-   Get m >>= f = Get (m >>= runGet . f)   {-# INLINE (>>=) #-} -  Get m >> Get n = Get (m >> n)-  {-# INLINE (>>) #-}- #if __GLASGOW_HASKELL__ < 808   fail msg = Get (lift (Left msg))   {-# INLINE fail #-}@@ -689,6 +683,11 @@   fail msg = Get (lift (Left msg))   {-# INLINE fail #-} #endif++-- | NOTE: @'Control.Applicative.empty' = 'fail' ""@.+instance Alternative Get where+  empty = fail ""+  Get (StateT m) <|> Get (StateT n) = Get $ StateT $ \s -> m s <> n s  -- | Run action, but return without consuming and key\/value pair. -- Fails if the action fails.
src/Data/BEncode/Internal.hs view
@@ -45,14 +45,23 @@ import Data.BEncode.BDict as BD  import GHC.Types++#if MIN_VERSION_integer_gmp(1, 1, 0)+import GHC.Num.Integer+#else import GHC.Integer.GMP.Internals+#endif  {-------------------------------------------------------------------- -- Serialization --------------------------------------------------------------------}  integerDecimal :: Integer -> B.Builder+#if MIN_VERSION_integer_gmp(1, 1, 0)+integerDecimal (IS i#) = B.intDec (I# i#)+#else integerDecimal (S# i#) = B.intDec (I# i#)+#endif integerDecimal  i      = B.string7 (show i) -- TODO more efficient  -- | BEncode format encoder according to specification.
tests/properties.hs view
@@ -66,6 +66,9 @@ prop_bencodable :: Eq a => BEncode a => T a -> a -> Bool prop_bencodable _ x = decode (BL.toStrict (encode x)) == Right x +emptyGet :: Get Int+emptyGet = A.empty+ main :: IO () main = hspec $ do   describe "BValue" $ do@@ -84,3 +87,9 @@       fromDict (fail "fatal error" :: Get Int) (BDict BE.Nil)            `shouldBe`        Left "fatal error"+    it "empty alternative is empty string" $ do+      fromDict emptyGet (BDict BE.Nil) `shouldBe` Left ""+    it "alternative composition" $ do+      fromDict (emptyGet <|> emptyGet) (BDict BE.Nil) `shouldBe` Left ""+      fromDict (pure 5 <|> emptyGet) (BDict BE.Nil) `shouldBe` Right 5+      fromDict (emptyGet <|> pure 3) (BDict BE.Nil) `shouldBe` Right 3