This works:
# f: unit => [> #A]
let f = () => #A
# f: unit => [> #B]
let g = () => #B
# h: int => [> #A | #B]
let h = i => i == 1 ? f() : g()
and the result of h
is int => [> #A | #B]
Now I want to limit f
and g
to return exact types:
let f: unit => [#A] = () => #A
let g: unit => [#B] = () => #B
let h = i => i == 1 ? f() : g()
^-^
This has type: [#B]
Somewhere wanted: [#A]
These two variant types have no intersection
How do I make h
to return [> #A|#B]
as in first example?