I really don't know what the correct title should be for this question, but:
I have a discriminatory union called MyDiscriminatedUnionin F#:
type MyDiscriminatedUnion =
| Foo of Foo
| Bar of Bar
where Fooand Barare the types of records:
type Foo = {
... }
type Bar = {
... }
I created a union type value Foo:
let foo = Foo {
... }
The compiler tells me that foo is of type MyDiscriminatedUnion.
Then I want to pass foo to a function that expects type Foo, not MyDiscriminatedUnion. Therefore, the compiler complains. How to tell the compiler what the Footype is Foo?
I tried:
let foo:Foo
when constructing a union type value.
I tried to omit foo in Foo:
foo :?> MyDiscriminatedUnion.Foo
but none of them work.
Please, help.
source
share