[Haskell-cafe] Data.Binary and error handling
Khudyakov Alexey
alexey.skladnoy at gmail.com
Sun Nov 29 18:33:42 EST 2009
В сообщении от 27 ноября 2009 23:55:47 Don Stewart написал:
> alexey.skladnoy:
> > It does but it was already noted that cereal uses strict bytestrings
> > which are not really convenient when dealing with huge inputs. One may
> > end up using both binary and cereal which is not really satisfactory.
>
> It is quite hard to do a good job of lazy input, but explicit checked
> errors (turning it into an Either Error a makes the whole stream
> strict!).
>
Surprisingly it seems that it's not possible to avoid "unexpected end of input
error" without forcing input. Primitive parsers fail in that case and only
reasonably way to check against this is 'remaining' function which forces
input. Moreover it's very inconvenient to check before significant fraction of
calls that input has sufficient length.
Of course it's possible to implement robust parsers with getWord8 & isEmpty
duo but this is theoretical possibility.
More information about the Haskell-Cafe
mailing list