fun{u}() “u” is a call union of function funfun(x (){u} -> I32) “u” is a type union. every union which is not a call union is a type union.
fn a()
pass
_ = a{u1}()
a{u2}()
x = a{u3}
the reason is we don’t know how it’s gonna get used later.
we can later possibly optimize for the common case of immediately calling a function.
due to 1, if a function’s parameter has a function type, we must also instantiate a new union for the parameter’s union.
fun2 = fn x: x
fun(fun2)
fun2 <= fn x: x + y
due to 1, if the return type of a function is a function type, we must instantiate a new union for the return type’s union.
function’s return types and parameter types have no difference in the way they interact with the type system.
despite 1, when calling a function, the function does not care about its own call union and does not generalize over it.
fn fun()
pass
fun{u1}()
fun{u2}() <- same function, different union.
due to 2 and 3, every union in the parameter or return will be part of the function’s scheme.
— assocs? TODO: should I produce same unions or is it undefined, possibly optimization.