packages feed

bsparse 0.0.3 → 0.0.4

raw patch · 2 files changed

+17/−1 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.ByteString.Parse: takeStorable :: Storable d => Parser d

Files

Data/ByteString/Parse.hs view
@@ -31,15 +31,21 @@     , skip     , skipWhile     , skipAll+    , takeStorable     ) where  import Control.Applicative import Control.Monad import Data.ByteString (ByteString) import qualified Data.ByteString as B+import qualified Data.ByteString.Internal as B (toForeignPtr) import Data.Word+import Foreign.Storable (Storable, peekByteOff, sizeOf)+import Foreign.ForeignPtr (withForeignPtr) import Prelude hiding (take, takeWhile) +import System.IO.Unsafe (unsafePerformIO)+ -- | Simple parsing result, that represent respectively: -- -- * failure: with the error message@@ -160,6 +166,16 @@                                 else err actual errMsg  ------------------------------------------------------------++-- | Take a storable from the current position in the stream+takeStorable :: Storable d+             => Parser d+takeStorable = anyStorable undefined+  where+    anyStorable :: Storable d => d -> Parser d+    anyStorable a = do+        (fptr, off, _) <- B.toForeignPtr <$> take (sizeOf a)+        return $ unsafePerformIO $ withForeignPtr fptr $ \ptr -> peekByteOff ptr off  -- | Take @n bytes from the current position in the stream take :: Int -> Parser ByteString
bsparse.cabal view
@@ -1,5 +1,5 @@ Name:                bsparse-Version:             0.0.3+Version:             0.0.4 Synopsis:            A simple unassuming parser for bytestring Description:         Really trivial parser to get and drop bytes from a bytestring License:             BSD3