ditto
ditto copied to clipboard
Is higher-kindedness worth it?
Currently the Ditto type system supports higher-kinded type variables, for example...
type IntContainer(f) = IntContainer(f(Int));
Here, f has the kind Type -> Type. This could be useful if you wanted to imitate typeclasses, as in...
get_int_container = fn (get: (f(a)) -> a, container: IntContainer(f)) -> Int = ...
Although this kind of thing goes against the KISS philosophy of the language.
The downside to supporting higher-kinded type variables like this is it makes the type-system incompatible with many other languages that we might like to target, e.g. TypeScript, Go, Dart.
Ahh defunctionalization can help us here. Worth reading this blog post:
https://towardsdev.com/a-guide-to-higher-kinded-type-classes-with-golang-36dab6c9ecc4