[Haskell-cafe] Laziness and Either
lemming at henning-thielemann.de
Mon Apr 21 15:52:34 EDT 2008
On Mon, 21 Apr 2008, Donn Cave wrote:
> On Apr 21, 2008, at 11:18 AM, John Goerzen wrote:
>> In the case of using "error", we can happily process the data assuming
>> everything will be fine, and raise an error if and when it is encountered.
>> By using Either, however, any pattern match on the Left/Right result is
>> going to force the entire input to be evaluated so that we can know whether
>> or not it had any error.
>> Is this analysis sensible? If so, are there better solutions?
> In another thread back on March 12 ("Exception handling when using
> I read `Since the decision between Left and Right requires all parts to be
> evaluated, it's Either that might too strict for your application. What about
> a writer monad, where exceptions, or better say warnings, are written to the
> writer stream?'
> I don't believe I ever got around to evaluating that recommendation (lazy
> evaluation strategy, indeed.) I think I would use "error".
Was this advise from me? I would advise the Writer monad again. 'error'
should be used only for programming errors, not for unexpected data or
situations from the outside world.
More information about the Haskell-Cafe