I am reading Expert F # 4.0 and at some point (p .93) the listfollowing syntax is introduced:
type 'T list =
| ([])
| (::) of 'T * 'T list
Although I understand conceptually what is happening here, I do not understand the syntax. Obviously, you can put []either ::between parentheses and they mean something special.
Other characters are not allowed, such as (++)or (||). So what is going on here?
And one more thing - the "operator" of nature (::). Suppose I have the following (strange) type:
type 'T X =
| None
| Some of 'T * 'T X
| (::) of 'T * 'T X
Now I can say:
let x: X<string> = Some ("", None)
but this is not allowed:
let x: X<string> = :: ("", None)
let x: X<string> = (::) ("", None)
So, (::)in fact, something is completely different than Some, although both are cases in a discriminatory association.