Can you give a code snippet how you would do it?
# functional
t
Can you give a code snippet how you would do it?
p
it's going to be a monster, there's no type-level programming in Kotlin
and I have no generalisation for it
t
hmm, that sucks. I guess I have to think of something else then
u
Are you able to express that in Haskell? I've tried but...
Coming from Haskell, what Kotlin is mostly missing are the Higher Kinded Types. It's a deliberate choice apparently, bc they are too complex for people to understand (which I disagree)
t
I'm sure there is some crazy way to do it in Haskell, especially if you consider extensions for dependent types. Perhaps something with type families would work, but my Haskell isn't good enough yet to come up with something right off the bat. I will ask the oracle and report back
Hopefully we will get HKTs eventually. The arrow guys are already working on a proposal for type classes, so if we ever get that it wouldn't make sense to stop at HKTs. Personally, what I'm missing the most is first class union types and type-level programming in general.
p
on the good news department HKTs are not an if anymore, just a when
đź’Ż 2
same for typeclasses
u
Really? I thought they put everything on hold... great!
p
#arrow-meta
u
Thanks I missed that. Still, as much as I enjoy tinkering around, a custom compiler plugin is not the same as having it supported by the language. :)
Kudos for the job and I will follow it closely
c
Count me in the dissenting (and apparently, very scarcely populated) crowd of people who understand Higher Kinded Types and who don't want to see them in Kotlin 🙂
t
And why is that?
c
I think overall, HKT’s don’t meet the requirement of a reasonable ratio for “complexity added to the language and compiler” / benefits
t
What do I care about the compiler though, someone else has to implement it
c
You have probably never used
scalac
🙂
r
HKTs as a compiler plugin has no complexity in usage because it’s transparent to the user.
Our current encoding in Arrow is problematic though since fix and Kind get in the way but with automatic typeclasses and kinds powered by Arrow meta and compiler plugins we can not only have higherkinded types but potentially intersection and union types too that are ergonomic to work with
Also resolution of typeclasses with kotlinc + arrow meta is way faster than scala because scala implodes search inside out based on scopes whereas our resolution which is already implemented can get to the instance directly since the lookup is coherent and predictable so it does not impose crazy compile times like scala’s implicits
It’s as fast as importing and looking up extension functions