I have defined a type called node along with a list of nodes.
type node = {name: string; description: string}
nodes = [] : list(node)
I have created a function called createNewNode() which creates a new node, assigns it to selectedNode, and adds it to the array nodes.
line 19: createNewNode() =
line 20: selectedNode = {name="" remoteFSRoot=""} : node
line 21: nodes = [nodes | selectedNode]
...
When I compile this I get the following error:
Error
File "node.opa", line 21, characters 10-32, (21:10-21:32 | 592-614)
Expression has type { hd: list(node); tl: node } / 'c.a but is coerced into
list('a).
Types { name: string; description: string } and
{ hd: 'a; tl: list('a) } / { nil } are not compatible
Hint:
One of the sum types may be missing the following cases of the
other:
{ nil }
{ hd tl }.
What does this compile message mean and how do I fix it?
I think you simply inversed
nodesandselectedNodeat Line 21 :