Consider that
type Foo =
| I of int
| S of string
let test = [ I(5); I(9); I(7)]
This works, but now I want "test" to be of type Foo and still be a list of either I or S. For example,
let test = L( [ I(5); I(9); I(42) ] ) //works!
let test2 = L( [ I(5); I(9); S("stuff") ] ) //type error
let test3 = L( [ I(5); I(9); L([]) ] ) //type error
I am trying this.
type Foo =
| I of int
| S of string
| L of 'T list when 'T :> Foo
I know this clearly does not work. For me it was just something natural.
Thank you very much for your help!
source
share