
5 Jun
2012
5 Jun
'12
5:24 a.m.
On Tue, 5 Jun 2012, Kazu Yamamoto (山本和彦) wrote:
Some functions in Data.Ratio call the error function. The following is an example:
recip (0:%_) = error "Ratio.%: zero denominator"
We cannot catch this error as ArithException since it is ErrorCall. Are there any reasons to not use ArithException?
It is intended that you do not divide by zero, also because it is so simple to check it before calling the function. The best solution would certainly be a number type that excludes zero values, such that division by zero can be catched at compile time. But currently Haskell's type system may not be expressive enough to handle this without a lot of explicit type conversion.