2 ms·
You can always use a fixed-precision numeric type. You might be thinking "what about libraries that require floating-point", and that's a good concern. Luckily
by adamch 7y ago
You can always use a fixed-precision numeric type.
You might be thinking "what about libraries that require floating-point", and that's a good concern. Luckily in Haskell there's the Num typeclass, so your libraries can let users use whatever fractional number type they'd like.
- a1369209993 7y agoFun fact, Num basically requires inf and nan unless you're willing to tolerate either terrible overflow (non-)handling (eg Int,SatInt) or memory blowup (eg Integer,BaireReal). # where R is some r such that Num r let huge = <the largest (finite) value in R> let inf = huge * huge # can't be finite unless you # truncate or saturate or something let nan = inf - inf # can't be either of # infinite (infinitely < +inf and > -inf), or # finite (catastrophic rounding errors) Num doesn't allow inf or nan to be Maybe R, so you're stuck filtering out in-band errors from a bare R.