Difference between revisions of "Num instance for functions"
Jump to navigation
Jump to search
.
(Formatting) |
(note about category) |
||
Line 16: | Line 16: | ||
<haskell>2 :: Integer</haskell> |
<haskell>2 :: Integer</haskell> |
||
! :-) |
! :-) |
||
+ | |||
+ | == Note == |
||
+ | |||
+ | This article is in category Proposals in order to show people that this idea was already proposed, |
||
+ | but that one should think twice implementing it. |
||
Revision as of 15:46, 10 May 2007
Some people have argued, that Num
instances of (->)
would be nice in order
to add functions nicely, say for
f, g :: Num a => b -> a
you would define
(f+g) x = f x + g x
With an according definition of fromInteger
fromInteger = const
numeric literals would also denote constant functions. This allows
f+2 == \x -> f x + 2
Even nicer, the mathematically established notation of omitting the multiplication dot
2(x+y) :: Integer
will now be parsed by a Haskell compiler to the most obvious meaning
2 :: Integer
! :-)
Note
This article is in category Proposals in order to show people that this idea was already proposed, but that one should think twice implementing it.