The reason that this is not working is that TreeNode
is a type, not a constructor. You have defined a type TreeNode
with a single union case called N
. In order to create a value of a Discriminated Union, you must use the name of one of it's union cases. In this example, there is only one to use - N
:
let test = N(1, [N(2, [])])
More info on unions can be found here.