from the documentation at https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/keyword-reference:
it looks like 'and' can be used in the four categories above. With records and constraints, I see the use cases. But can anyone illustrate the uses in let bindings and members?
I see an example in this gist: https://gist.github.com/theburningmonk/3199252 but I'm not sure how it works.
For let bindings and members, the and
keyword is used for definining mutually recursive types and functions. A silly example with functions:
let rec f x = g x + 1
and g x = f x - 1
A silly example with classes:
type A() =
member x.B = B()
and B() =
member x.A = A()
The case with classes really covers all possible type definitions, including records and discriminated unions:
type A =
| Aaa of int
| Aaaa of C
and C =
{ Bbb : B }
and B() =
member x.Bbb = Aaa 10
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