packages feed

ptr 0.16.1 → 0.16.2

raw patch · 4 files changed

+25/−5 lines, 4 files

Files

library/Ptr/Parse.hs view
@@ -173,15 +173,15 @@   {-# SCC "bytesWhile" #-}   Parse $ \ !availableAmount !ptr failWithEOI failWithMessage succeed ->   let-    iterate !availableAmount !unconsumedAmount !ptr =+    iterate !availableAmount !unconsumedAmount !currentPtr =       if unconsumedAmount > 0         then do-          byte <- C.peek ptr+          byte <- C.peek currentPtr           if predicate byte-            then iterate availableAmount (pred unconsumedAmount) (plusPtr ptr 1)+            then iterate availableAmount (pred unconsumedAmount) (plusPtr currentPtr 1)             else do               bytes <- B.packCStringLen (castPtr ptr, availableAmount - unconsumedAmount)-              succeed bytes unconsumedAmount ptr+              succeed bytes unconsumedAmount currentPtr         else failWithEOI 0     in iterate availableAmount availableAmount ptr 
library/Ptr/Poking.hs view
@@ -140,3 +140,12 @@     LocalTime date (TimeOfDay hour minute second) = utcToLocalTime utc utcTime     (year, month, day) = toGregorian date +{-# INLINE list #-}+list :: (element -> Poking) -> [element] -> Poking+list element =+  loop mempty+  where+    loop state =+      \ case+        head : tail -> loop (state <> word8 1 <> element head) tail+        _ -> state <> word8 0
ptr.cabal view
@@ -1,7 +1,7 @@ name:   ptr version:-  0.16.1+  0.16.2 category:   Ptr, Data synopsis:
tests/Main.hs view
@@ -12,6 +12,7 @@ import qualified Ptr.PokeAndPeek as E import qualified Ptr.ByteString as A import qualified Ptr.Poking as F+import qualified Ptr.Parse as G import qualified Data.ByteString as D  @@ -39,6 +40,16 @@       testCase "asciiUtcTimeInIso8601" $ do         assertEqual "" "2017-02-01T05:03:58Z" (A.poking (F.asciiUtcTimeInIso8601 (read "2017-02-01 05:03:58")))     ]+    ,+    parsing+  ]++parsing :: TestTree+parsing =+  testGroup "Parsing" $+  [+    testCase "" $+    assertEqual "" "123" (A.parse "123456" (G.bytesWhile (< 52)) undefined undefined)   ]  pokeThenPeek :: B.Poke a -> C.Peek a -> Maybe (a -> a)