cereal
cereal copied to clipboard
lookAhead and bytesRead
While lookAhead
does not consume the input, it does update the bytesRead
.
test = do
x <- bytesRead
_ <- lookAhead getInt64be
y <- bytesRead
return (x, y)
> runGet test (encode (2 :: Int)) -- result: Right (0, 8)
I suspect this is not the desired behaviour, and that the above example should return (0, 0)
, to reflect that no bytes of the input have been consumed. If this is the desired behaviour, it should probably be documented.
This seems like a bug to me, good find!
Seems to me it's all the less likely to be the desired behavior that the same code does return (0,0)
when run against binary
.