packages feed

bencoding 0.4.2.1 → 0.4.3.0

raw patch · 3 files changed

+27/−2 lines, 3 files

Files

ChangeLog view
@@ -1,3 +1,7 @@+2013-12-19  Sam Truzjan  <pxqr.sta@gmail.com>++	* 0.4.3.0: Add lookAhead and match functions.+ 2013-12-16  Sam Truzjan  <pxqr.sta@gmail.com>  	* 0.4.2.1: Override default Monad(fail) method so it is possible
bencoding.cabal view
@@ -1,5 +1,5 @@ name:                  bencoding-version:               0.4.2.1+version:               0.4.3.0 license:               BSD3 license-file:          LICENSE author:                Sam Truzjan@@ -29,7 +29,7 @@   type:                git   location:            git://github.com/cobit/bencoding.git   branch:              master-  tag:                 v0.4.2.1+  tag:                 v0.4.3.0  library   default-language:    Haskell2010
src/Data/BEncode.hs view
@@ -78,11 +78,13 @@        , Result        , decodingError        , fromDict+       , lookAhead         , next        , req        , opt        , field+       , match         , (<$>!)        , (<$>?)@@ -671,6 +673,15 @@   fail msg = Get (lift (Left msg))   {-# INLINE fail #-} +-- | Run action, but return without consuming and key\/value pair.+-- Fails if the action fails.+lookAhead :: Get a -> Get a+lookAhead (Get m) = Get $ do+  s <- get+  r <- m+  put s+  return r+ -- | Get lexicographical successor of the current key\/value pair. next :: Get BValue next = Get (StateT go)@@ -703,6 +714,16 @@ field m = Get $ do   v <- runGet m   either throwError pure $ fromBEncode v++-- | Match key with value.+match :: BKey -> BValue -> Get ()+match key expected = do+  actual <- req key+  if actual == expected+    then return ()+    else fail $ "key match failure(" ++ show key ++ "): " +++                "expected = " ++ show expected +++                "actual   = " ++ show actual  -- | Shorthand for: @f '<$>' 'field' ('req' k)@. (<$>!) :: BEncode a => (a -> b) -> BKey -> Get b