Re: [Haskell-cafe] function arithmetic?

On 08/31/2013 09:27 PM, Charlie Paul wrote:
I believe that this is what you want: http://www.haskell.org/haskellwiki/Num_instance_for_functions
On Sat, Aug 31, 2013 at 10:01 PM, Christopher Howard
wrote:
The author seemed to be subtly mocking the idea. It seemed to be suggesting that a Num instance for functions would imply the need for constant number functions, which leads to difficulties. But I don't see why one would have to take it that far. In any case, I just tried the NumInstances package from Hackage and it seems to work great.

On 1/09/2013, at 7:06 PM, Christopher Howard wrote:
It seemed to be suggesting that a Num instance for functions would imply the need for constant number functions, which leads to difficulties. But I don't see why one would have to take it that far.
You *cannot* make a type an instance of Num without saying how to map integer literals to that type. If you want (f+g)x = fx + gx then having 2x = 2 makes perfect sense, because then (f+2)x = fx + 2 just as an APL or S programmer would expect. The fact that 2(x+y) will then evaluate to 2 without evaluating x or y is unfortunate, but inevitable. I'm sure I could live with it.
participants (2)
-
Christopher Howard
-
Richard A. O'Keefe