[Haskell-cafe] How to catch exception within the Get monad (the Binary package)

Dimitry Golubovsky golubovsky at gmail.com
Tue Sep 7 21:58:20 EDT 2010


Henning,

On Tue, Sep 7, 2010 at 12:51 PM, Henning Thielemann
<schlepptop at henning-thielemann.de> wrote:


> This solution looks very ugly to me. Catching 'error's is debugging, but
> parser failure is kind of exception handling. I guess, the errors you
> want to catch are caused by non-supported fail method, right? Can't you
> use a monad transformer like explicit-exception:Synchronous.Exception or
> transformers:ErrorT around the Binary parser?

Alexey already replied, but after looking at the way Binary processes
parser errors I came to the same conclusion: it is by design that it
falls hard when data cannot be deserialized (btw makes sense in many
cases, but not in mine).

I am beginning to realize that probably (de)serializing lazy
structures is not a good idea at all since such structure may be
consumed in pure code, and such parser errors are hidden inside, and
may "fire" at any moment. Any complications to the binary parser will
bring performance penalty. Or weird solutions like mine are needed.

Thanks.

-- 
Dimitry Golubovsky

Anywhere on the Web


More information about the Haskell-Cafe mailing list