[Haskell-cafe] Re: A question about "monad laws"
rl at cse.unsw.edu.au
Wed Feb 13 23:00:15 EST 2008
jerzy.karczmarczuk at info.unicaen.fr wrote:
> Roman Leshchinskiy writes:
>> Richard A. O'Keefe wrote:
>>> jerzy.karczmarczuk at info.unicaen.fr wrote:
>>>> Would you say that *no* typical floating-point software is reliable?
>>> With lots of hedging and clutching of protective amulets around the
>>> word "reliable", of course not. What I *am* saying is that
>>> (a) it's exceptionally HARD to make reliable because although the
>>> are well defined and arguably reasonable they do NOT obey the laws that
>>> school and university mathematics teach us to expect them to obey
>> Ints do not obey those laws, either. It is not exceptionally hard to
>> write reliable software using ints. You just have to check for
>> exceptional conditions. That's also the case for floating point.
>> That said, I suspect that 90% of programs that use float and double
>> would be much better off using something else. The only reason to use
>> floating point is performance.
> I have a bit different perspective...
> First, when I see the advice "use something else", I always ask "what",
> and I get an answer very, very rarely... Well? What do you propose?
For Haskell, Rational seems like a good choice. The fact that the
standard requires defaulting to Double is quite unfortunate and
inconsistent, IMO; the default should be Rational. Float and Double
shouldn't even be in scope without an explicit import. There really is
no good reason to use them unless you are writing a binding to existing
libraries or really need the performance.
> Then, the problem is not always pathological, in the sense of "exceptional
> conditions". There are touchy points related to the stability of the
> algorithms for the solution of differential equations. There are doubtful
> random number generators in Monte-Carlo business. There are ill-conditioned
> matrices and screwed-up iterative definitions. Algorithms work, work, and
> ultimately explode or produce rubbish. The "laws" which get broken are
> "almost" respected for a long time, and then we have the Bald Man (Sorites)
> RAO'K very wisely says that people should avoid reinventing wheels, and
> they should use established packages, written by people who know.
Yes, I completely agree with that (even though my original email
probably didn't sound as if I did). My point was that (a) most people
don't need floating point and (b) those who do need it should learn how
to use it.
> The problem *here* is that we would like to have something fabulous in
> Haskell - for example...
I think we mostly have it already.
More information about the Haskell-Cafe