How to read F# type signatures?

后端 未结 4 883
死守一世寂寞
死守一世寂寞 2021-02-13 10:37

I\'m struggling with the F# type signature notation. For example let\'s say you have a Fold function:

let rec Fold combine acc l =
...

that may

4条回答
  •  故里飘歌
    2021-02-13 11:17

    The reason for that is in Functional programming every function actually has only one parameter.

    So lets say you have a function called Sum as :

    int -> int -> int
    

    It takes 2 int and return one int. Now if you call this function by just passing one int you won't get any compiler error, rather the return value will be of type int -> int. So you see this arrow notation fits with this behavior. This behavior is known as Currying. Check out : http://en.wikipedia.org/wiki/Currying

提交回复
热议问题