You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mutual recursion sample for F# record types. #14399
Sorry, I should have pointed out why and given a corrected sample.
The 'and' is not required for the current example data structure, just moving the Address type to be defined first obviates the need for it.
This version is mutually recursive and cannot be defined without the 'and' as now both types refer to each other.
// Create a Person type and use the Address type that is not defined
type Person =
{ Name: string
Age: int
Address: Address }
// Define the Address type which is used in the Person record
and Address =
{ Line1: string
Line2: string
PostCode: string
ReturnTo: Person option }
Activity
cartermp commentedon Sep 12, 2019
@davidn-sytelco The example is indeed a mutually recursive type declaration. Mutual recursion isn't a term limited to just functions.
davidn-sytelco commentedon Sep 12, 2019
Sorry, I should have pointed out why and given a corrected sample.
The 'and' is not required for the current example data structure, just moving the Address type to be defined first obviates the need for it.
This version is mutually recursive and cannot be defined without the 'and' as now both types refer to each other.
// Create a Person type and use the Address type that is not defined
type Person =
{ Name: string
Age: int
Address: Address }
// Define the Address type which is used in the Person record
and Address =
{ Line1: string
Line2: string
PostCode: string
ReturnTo: Person option }
Update mutually recursive definition sample
cartermp commentedon Sep 15, 2019
Thanks @davidn-sytelco, I updated the sample.
Update mutually recursive definition sample (#14448)