From: Magnus Therning <magnus@therning.org>
On 24/08/10 03:47, John Millikin wrote:
[...]
> I would like to avoid hard-coding the error type to SomeException, because
> it forces libraries to use unsafe/unportable language features (dynamic
> typing and casting). However, given the apparent practical requirement that
> all iteratees have the same error type, it seems like there's no other
> choice.
I haven't worked enough with iteratees to have an informed opinion on this,
but I wonder what the pros and cons are of having an error state in the
iteratees at all. In other words, why would this
data Step a m b
= Continue (Stream a -> Iteratee a m b)
| Yield b (Stream a)
| Error E.SomeException
be preferred over this
data Step a m b
= Continue (Stream a -> Iteratee a m b)
| Yield b (Stream a)
(Maybe with the restriction that m is a MonadError.)
Oleg included the error state to enable short-circuiting of computation, and I guess everyone just left it in. Recently I've been wondering if it should be removed, though, in favor requiring explicit (i.e. explicit in the type sig) exceptions for everything. I'm not sure if that would be more or less complicated.
John