Can someone describe this F# expression to me?
val augment: GameGrid -> points -> unit
What does the val
keyword mean?
Is it true that usually indicates a function that returns the specified type? 指示返回指定类型的函数是否正确? So does indicate a function that returns a function that returns the specified type? 表示返回一个返回指定类型的函数的函数?
(The 'val' bit is not an expression; offhand I think it can appear in three different contexts:
and none of those are technically expression contexts.)
As for the type, indeed
A1 -> A2 -> R
means a function that takes an A1, and returns a function that takes an A2 and returns an R. The arguments are curried, and it may do you well to read eg
F# function types: fun with tuples and currying
which describes currying and partial application in more detail.
How did you get this output? In FSI?
Val just indiciates a definition of a value.
Eg if you wrote the following in C#
private void Foo(int i);
you would write this in F#
val Foo : int -> unit
Concerning type -> type -> type
: This is a function with two parameters (type) returning `type´
Eg
let plus a b = a + b
has got signature int -> int -> int
.
Your idea with a function that returns a function is actually correct. This is a very interesting technique in many functional languages called currying
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.