Re: [Haskell-cafe] Why not some subclass of Floating to model NaNs as some handleable bottom?

Dear Yue, Bottom has much weaker semantics than an exception: it means You may never get a result and thus will never handle it! Another reason is convenience: it is frequently the case that giving NaN in a row of numbers is much more informative than crashing a program with an exception and never printing the result anyway. Finally IEEE special values have clear propagation semantics: they are basically Maybe on steroids. The problem with this approach is indeed a silent handling. But in order to fix this, it is better to add preconditions to specific algorithms that do not allow IEEE special value on input (`isFinite` or `isNotNaN`) and then track the origin of the special value with the methods like those described here: https://skillsmatter.com/skillscasts/14905-agile-functional-data-pipeline-in... Never throw an error without telling exactly why it happened and exactly where to fix it :-). Using bottom is last resort; exceptions likewise. -- Cheers MichaĆ
participants (1)
-
Michal J Gajda