# Num instance for functions

### From HaskellWiki

(Difference between revisions)

(Category:FAQ, misspelling reflected the change precisely, but it was not the intended one) |
(→See also: applicative-numbers link) |
||

Line 26: | Line 26: | ||

== See also == |
== See also == |
||

+ | * The [[applicative-numbers]] package, which generates numeric class instances for arbitrary [[applicative functor]]s (including functions). |
||

* http://www.haskell.org/pipermail/haskell-cafe/2006-November/019374.html |
* http://www.haskell.org/pipermail/haskell-cafe/2006-November/019374.html |
||

* http://www.haskell.org/pipermail/haskell-cafe/2006-October/019105.html |
* http://www.haskell.org/pipermail/haskell-cafe/2006-October/019105.html |

## Revision as of 00:14, 28 April 2009

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

! :-)

## 1 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. There should be a category Counterproposals.

## 2 See also

- The applicative-numbers package, which generates numeric class instances for arbitrary applicative functors (including functions).
- http://www.haskell.org/pipermail/haskell-cafe/2006-November/019374.html
- http://www.haskell.org/pipermail/haskell-cafe/2006-October/019105.html
- http://www.haskell.org/pipermail/haskell-cafe/2001-February/001531.html