ditto icon indicating copy to clipboard operation
ditto copied to clipboard

Is higher-kindedness worth it?

Open jmackie opened this issue 3 years ago • 2 comments

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.

jmackie avatar Oct 18 '22 12:10 jmackie

Ahh defunctionalization can help us here. Worth reading this blog post:

https://towardsdev.com/a-guide-to-higher-kinded-type-classes-with-golang-36dab6c9ecc4

jmackie avatar Feb 18 '23 07:02 jmackie

Ahh defunctionalization can help us here

Note that fp-ts does this.

jmackie avatar Feb 26 '23 16:02 jmackie