jfecher / ante

A safe, easy systems language
http://antelang.org
MIT License
1.9k stars 80 forks source link

Implement effect variable ellision #191

Open jfecher opened 8 months ago

jfecher commented 8 months ago

If an effect type variable is excluded, one can be automatically inserted into a function type:

add: U32 -> U32 becomes add: U32 -> U32 can e

This simplifies type signatures. Similarly, if a function is used as a parameter, we can assume it will be called within the function:

map: Stream a - (a -> b can e) -> Unit can Emit b, e

vecmap: Vec a - (a -> b can e) -> Vec b can e

Would be able to be written as:

map: Stream a - (a -> b) -> Unit can Emit b

vecmap: Vec a - (a -> b) -> Vec b

This would be a simple syntactic injection of an effect variable if one wasn't already present. Since the check is just syntactic, types inferred and displayed by the compiler can also omit effect variables if the function uses just one. If a function passed in as a parameter is ever not called, a different effect variable would need to be manually specified:

make_function_object: (a -> b can e1) -> FunctionObj can e2