[Haskell-cafe] Function Precedence

jerzy.karczmarczuk at info.unicaen.fr jerzy.karczmarczuk at info.unicaen.fr
Wed Apr 2 08:27:31 EDT 2008

Hans Aberg comments my remark to his observation: 

>>> But one should also be able to write (f+g)(x). - This does not  work  in 
>>> Haskell, because Num requires an instance of Eq and Show.
>> So, declare them, even if they are vacuous. I did it several times,  I am
>> still alive, so no need to say "this does not work".
> That is possible, of course - I did that, too. But it means that the  
> syntax and semantics do not work together; an invitation to pitfalls.  So 
> this ought to be avoided, except if there are no other workarounds.

I am more tolerant. The question - for me - is not an interplay between
syntax and semantics, syntax here is irrelevant, the fact that (+) is a
popular infix operator plays no role. The calamity comes from the fact that
it is not possible to write serious and "natural" instances of Eq and
Show for functions, and that for God knows which reasons, the Num instance
demands them ! This requirement is not rational, although intuitive. But
I violated it several times, when I needed arithmetic for lazy infinite
objects... So, I can't say that this should be avoided. I don't see
"obvious" pitfalls therein. 

> It would be better to write a new Prelude. :-)

Oh, yes, our common dream... 

Jerzy Karczmarczuk 

More information about the Haskell-Cafe mailing list