Adding binary to the Haskell Platform

Don Stewart dons at galois.com
Wed Aug 5 16:34:43 EDT 2009


alexander.dunlap:
> To add to the laundry list of problems with Data.Binary, I don't like
> the fact that decode calls error on invalid input. I can't think of
> any great alternatives (using Maybe as the result type would be too
> strict, of course, and returning partial results would be difficult
> with polymorphism), but it seems a bit unclean that decode has to be
> used with the IO monad to catch the errors. (Of course, the only
> reason you would have bad input would be if you were using the IO
> monad, so the practical implications are not great, but still, it
> would be nice if there was a better way.)

That's right. Originally, it used a custom Either type, but it isn't
possible to stream decoders that way.

I'd consider it an intentional design feature.

-- Don


More information about the Libraries mailing list