Data.Ratio and exceptions

Henning Thielemann lemming at henning-thielemann.de
Tue Jun 5 11:59:12 CEST 2012


On Tue, 5 Jun 2012, Kazu Yamamoto (山本和彦) wrote:

> Hello Henning,
>
> Thank you for reply.
>
>> It is intended that you do not divide by zero, also because it is so
>> simple to check it before calling the function.
>
> I'm not convinced. For instance, for division by zero of Int, it is
> also easy to check it before calling the "div" function. But we have
> DivideByZero.


I know people get annoyed quickly if I start a new round of "errors vs. 
exceptions" ...

In Haskell there is only one undefined value and that should be equivalent 
to an infinite loop. Every distinction between 'error', 'undefined', 
infinite loop, DivideByZero is only for debugging purposes. Don't rely on 
being able to catch them! The only correct way to cope with division by 
zero is to not let it happen.


More information about the Libraries mailing list