@tsnobip you’ve connected the dots with these two:
-
let foo : 'a = 1and… - all branches of a switch need to return the same type.
Thank you for pointing this out!
Can I say that I “trigger” the unification by handling the value of type expect<'t> within the Http.get function? This is because the compiler can infer the types by values and because there are two branches (expectJson and expectText), one of which takes a generic 't, the compiler “narrows” it down to the first most concrete type, which is string, isn’t it?
If I add another variant, say ExpectInt(int => result<int, string>) and handle it in my switch like so ExpectInt(val) => val(42) // decoding an int, then the compiler complains about this line with int vs string.