FsUnit source code contains an unusual definition:
let be = id
FSI output:
val was : ('a -> 'a)
The semantics of the "id" is the parenthesized form of the following statement:
let be x = x
FSI output:
val be : 'a -> 'a
You can see the slight difference: the latter example replaces expression be true with true, while the first syntax would represent it as (true).
What puzzles me is that I can't find any reference to "id" in F# language reference, neither it is described in a "Programming F#" book. Moreover, "id" is not a reserved keyword, I can define assign "id" to something else, and then I no longer can use it in a way that is shown in the first example. So I wonder if there are any F# documents that describe this literal and its semantics.
Most of these built-in functions are defined in the FSharp.Core
library, Microsoft.FSharp.Core.Operators
module.
They're documented on MSDN. Here's id
: http://msdn.microsoft.com/en-gb/library/ee353607.aspx
This doesn't look like a literal at all. It looks more like a function. Specifically, guessing by the signature and the name, it looks like the identity function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With