Understanding parameters in Haskell -


i new haskell , trying call function got from: http://www.haskell.org/haskellwiki/functional_differentiation

  derive :: (fractional a) => -> (a -> a) -> (a -> a)   derive h f x = (f (x+h) - f x) / h 

i having trouble understanding parameters of method , h f x correspond to.

from understand:

h fractional

f function takes in fractional , returns fractional

x ?? come from?

however when type in ghci:

prelude> let derive h f x = (f (x+h) - f x) / h prelude> :t derive derive :: fractional => -> (a -> a) -> -> prelude> 

i different type out of it.

what going on? kind of currying?

it indeed currying. (fractional a) => -> (a -> a) -> (a -> a) , fractional => -> (a -> a) -> -> a same type because -> right associative.

take add x y = x + y. type int -> int -> int ~ int -> (int -> int). add 5 function takes int , adds 5 it.

the reason 1 might write first form may put emphasis on usage of curried form of function.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -