@@ -33,15 +33,14 @@ runDecodeIO (Decode dec) bs = do
|
33 | 33 | embedIO :: IO a -> Decode a
|
34 | 34 | embedIO action = Decode $ Peek $ \_ ptr -> do
|
35 | 35 | v <- action
|
36 |
| -return (ptr, v) |
| 36 | +pure (PeekResult ptr v) |
37 | 37 |
|
38 | 38 | {-# INLINE prim #-}
|
39 | 39 | prim :: Int -> (Ptr Word8 -> IO a) -> Decode a
|
40 | 40 | prim len f = Decode $ Peek $ \ps ptr -> do
|
41 | 41 | !v <- f ptr
|
42 | 42 | let !newPtr = ptr `plusPtr` len
|
43 |
| -return (newPtr, v) |
44 |
| --- return $ PeekResult newPtr v |
| 43 | +pure (PeekResult newPtr v) |
45 | 44 |
|
46 | 45 | -- Public
|
47 | 46 |
|
@@ -54,16 +53,14 @@ getByteString :: Int -> Decode B.ByteString
|
54 | 53 | getByteString len = Decode $ Peek $ \ps ptr -> do
|
55 | 54 | bs <- B.packCStringLen (castPtr ptr, len)
|
56 | 55 | let !newPtr = ptr `plusPtr` len
|
57 |
| --- return $ PeekResult newPtr bs |
58 |
| -return (newPtr, bs) |
| 56 | +pure (PeekResult newPtr bs) |
59 | 57 |
|
60 | 58 | {-# INLINE getByteStringNull #-}
|
61 | 59 | getByteStringNull :: Decode B.ByteString
|
62 | 60 | getByteStringNull = Decode $ Peek $ \ps ptr -> do
|
63 | 61 | bs <- B.packCString (castPtr ptr)
|
64 | 62 | let !newPtr = ptr `plusPtr` (B.length bs + 1)
|
65 |
| --- return $ PeekResult newPtr bs |
66 |
| -return (newPtr, bs) |
| 63 | +pure (PeekResult newPtr bs) |
67 | 64 |
|
68 | 65 | {-# INLINE getWord8 #-}
|
69 | 66 | getWord8 :: Decode Word8
|
@@ -95,12 +92,12 @@ getInt64BE = fromIntegral <$> getWord64BE
|
95 | 92 |
|
96 | 93 | {-# INLINE getFloat32BE #-}
|
97 | 94 | getFloat32BE :: Decode Float
|
98 |
| -getFloat32BE = prim 4 $ \ptr -> byteSwap32 <$> peek (castPtr ptr) |
| 95 | +getFloat32BE = prim 4 $ \ptr -> byteSwap32 <$> peek (castPtr ptr) |
99 | 96 | >>= wordToFloat
|
100 | 97 |
|
101 | 98 | {-# INLINE getFloat64BE #-}
|
102 | 99 | getFloat64BE :: Decode Double
|
103 |
| -getFloat64BE = prim 8 $ \ptr -> byteSwap64 <$> peek (castPtr ptr) |
| 100 | +getFloat64BE = prim 8 $ \ptr -> byteSwap64 <$> peek (castPtr ptr) |
104 | 101 | >>= wordToFloat
|
105 | 102 |
|
106 | 103 | {-# INLINE wordToFloat #-}
|
|
0 commit comments