Haskell's type system treats a numerical value as function?
Posted
by Long
on Stack Overflow
See other posts from Stack Overflow
or by Long
Published on 2010-03-22T23:20:27Z
Indexed on
2010/03/23
0:11 UTC
Read the original article
Hit count: 515
haskell
After playing around with haskell a bit I stumbled over this function:
Prelude Data.Maclaurin> :t ((+) . ($) . (+))
((+) . ($) . (+)) :: (Num a) => a -> (a -> a) -> a -> a
(Data.Maclaurin is exported by the package vector-space.) So it takes a Num, a function, another Num and ultimately returns a Num. What magic makes the following work?
Prelude Data.Maclaurin> ((+) . ($) . (+)) 1 2 3
6
2 is obviously not a function (a->a) or did I miss out on something?
© Stack Overflow or respective owner