@@ -33,15 +33,14 @@ runDecodeIO (Decode dec) bs = do
3333embedIO :: IO a -> Decode a
3434embedIO action = Decode $ Peek $ \ _ ptr -> do
3535 v <- action
36- return ( ptr, v)
36+ pure ( PeekResult ptr v)
3737
3838{-# INLINE prim #-}
3939prim :: Int -> (Ptr Word8 -> IO a ) -> Decode a
4040prim len f = Decode $ Peek $ \ ps ptr -> do
4141 ! v <- f ptr
4242 let ! newPtr = ptr `plusPtr` len
43- return (newPtr, v)
44- -- return $ PeekResult newPtr v
43+ pure (PeekResult newPtr v)
4544
4645-- Public
4746
@@ -54,16 +53,14 @@ getByteString :: Int -> Decode B.ByteString
5453getByteString len = Decode $ Peek $ \ ps ptr -> do
5554 bs <- B. packCStringLen (castPtr ptr, len)
5655 let ! newPtr = ptr `plusPtr` len
57- -- return $ PeekResult newPtr bs
58- return (newPtr, bs)
56+ pure (PeekResult newPtr bs)
5957
6058{-# INLINE getByteStringNull #-}
6159getByteStringNull :: Decode B. ByteString
6260getByteStringNull = Decode $ Peek $ \ ps ptr -> do
6361 bs <- B. packCString (castPtr ptr)
6462 let ! newPtr = ptr `plusPtr` (B. length bs + 1 )
65- -- return $ PeekResult newPtr bs
66- return (newPtr, bs)
63+ pure (PeekResult newPtr bs)
6764
6865{-# INLINE getWord8 #-}
6966getWord8 :: Decode Word8
@@ -95,12 +92,12 @@ getInt64BE = fromIntegral <$> getWord64BE
9592
9693{-# INLINE getFloat32BE #-}
9794getFloat32BE :: Decode Float
98- getFloat32BE = prim 4 $ \ ptr -> byteSwap32 <$> peek (castPtr ptr)
95+ getFloat32BE = prim 4 $ \ ptr -> byteSwap32 <$> peek (castPtr ptr)
9996 >>= wordToFloat
10097
10198{-# INLINE getFloat64BE #-}
10299getFloat64BE :: Decode Double
103- getFloat64BE = prim 8 $ \ ptr -> byteSwap64 <$> peek (castPtr ptr)
100+ getFloat64BE = prim 8 $ \ ptr -> byteSwap64 <$> peek (castPtr ptr)
104101 >>= wordToFloat
105102
106103{-# INLINE wordToFloat #-}
0 commit comments