Wow, that's cool!
You should consider making this a library for java!
The problem is that Java's type system is not able to express these powerful abstractions. I've added the code for mapAccumR to the article. You can see that it requires any traversable t and later as third argument is t b meaning this traversable t contains a b, whatever that might be. In Java terms: t is Generic, kinda like <T extends Traversable>, the problem is the B. You cannot have generic generics in Java (also called higher-order types).
<T extends Traversable>
mapAccumR<T extends Traversable, B>(/* ... */, T<B> x)
is not valid Java
Well, challenge accepted. I shall find a work around!
Wish me luck!
Arrow-kt implement support of higher kinded types for Kotlin (which has a similar limitation). They create a type using generic Kind<T, B> and some tools to convert it to usable Kotlin type.
Suggest you to check it out!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.