[Haskell-cafe] Haskell and the Software design process

John Lato jwlato at gmail.com
Tue May 4 11:00:23 EDT 2010


On Tue, May 4, 2010 at 2:09 PM, Limestraël <limestrael at gmail.com> wrote:
> 2010/5/4 John Lato <jwlato at gmail.com>
>>
>> "Crashing at the point of the error" isn't necessarily useful in
>> Haskell due to lazy evaluation.  The code will crash when the result
>> of the partial function is evaluated, which may be quite far away (in
>> terms of function calls) from where the programmer would expect.
>
> Is that why Haskell can't provide a traceback when exceptions are raised?

I'm not really the right person to answer this, but I believe this is
roughly true.

> Are there other methods than Maybe or exceptions to handle the errors in
> Haskell? Is the monad Error(T) useful?

There are many other ways of handling errors/exceptional conditions.
Maybe, Either, ErrorT, abuse of monad fail, explicit-exception [1] and
attempt [2] are some of them; there are others.  Which is appropriate
depends upon the use case.

The difficulty is gluing together libraries that use different
mechanisms (attempt addresses this to some extent).  And of course
exceptions, which are unavoidable but often neglected because they're
invisible at the type level.

[1] http://hackage.haskell.org/package/explicit-exception
[2] http://hackage.haskell.org/package/attempt

John


More information about the Haskell-Cafe mailing list