I have a record :
type node = {
content : string;
parent : node option;
branch : string option;
children : seq<node> option;
}
Which I want to instantiate this way :
let rec treeHead = {
content = "Value"
parent = None;
branch = None;
children = tree (Some(treeHead)) rows;
};
Where
let rec tree (parent:node option) (rows:seq<CsvRow>) :seq<node> option
Is a a recursive function that gets the children of a node (to construct a tree). So as you can see the object treeHead needs to call itself through the tree function.
I want to it this way to avoid using treeHead as a mutable value and change its children property after.
My question is that the treeHead is raising an error and a warning. The error says :
The value 'treeHead' will be evaluated as part of its own definition.
And the warning says :
This and other recursive references to the object(s) being defined will be checked for initialization-soundness at runtime through the use of a delayed reference. This is because you are defining one or more recursive objects, rather than recursive functions. This warning may be suppressed by using '#nowarn "40"' or '--nowarn:40'.
First, am I doing this the right way (I mean, not considering the mutable choice) ? And how should I correct this.