How to read F# type signatures?

后端 未结 4 872
死守一世寂寞
死守一世寂寞 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:18

    The signatures are written in that way because of what is called Currying. A slightly more accurate way of describing your function is that it takes a (function that takes a 'a and returns a function from a 'b to a 'a) and returns a function that takes a 'a and returns a function from a list<'b> to a 'a. Because of this the type signature can be rewritten as

    ('a -> 'b -> 'a) -> ('a -> (list<'b> -> 'a))
    

提交回复
热议问题