[Haskell-cafe] Either Monad and Laziness

Evan Laforge qdunkan at gmail.com
Tue Sep 11 20:48:43 CEST 2012

On Tue, Sep 11, 2012 at 9:36 AM, Eric Velten de Melo
<ericvmelo at gmail.com> wrote:
> Any thoughts? Hopefully I'm not saying anything really stupid.

You can intersperse decoding errors in the output, e.g. output is
[Either Error DecodedChunk].  Then all the processors have to deal
with it, but if you just want to pass the error through then just 'map
. fmap' instead of 'map'.  This means processors can also inject their
own errors or logs into the output, which may be very useful.

Or you could use runtime exceptions, i.e. the decoder is lazy but can
call error.  This is bad for reliability but if you know you always
want to crash on a bad parse it keeps the return value simple.

More information about the Haskell-Cafe mailing list