# Num instance for functions

### From HaskellWiki

(Difference between revisions)

(merely a copy of my mail to Haskell-Cafe) |
(more Humor than Proposal) |
||

Line 25: | Line 25: | ||

+ | [[Category:Humor]] | ||

[[Category:Proposals]] | [[Category:Proposals]] |

## Revision as of 13:08, 17 April 2007

Some people have argued, thatNum

(->)

to add functions nicely, say for

f, g :: Num a => b -> a

you would define

(f+g) x = f x + g x

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

! :-)