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.Corelibrary,Microsoft.FSharp.Core.Operatorsmodule.They’re documented on MSDN. Here’s
id: http://msdn.microsoft.com/en-gb/library/ee353607.aspx