Also, if I understand it correctly, higher kinds a...
# arrow
b
Also, if I understand it correctly, higher kinds are just type constructors. But don't ask me how
Either l r :: * -> * -> *
is implemented via
Kind<F, A>
in Arrow
s
It's just
Kind<Kind<F, A>, B
or
Kind2<F, A, B>
.
You can see
Kind
as the way to apply a type argument to a type constructor. If we say that
List
is a type constructor that takes 1 type argument (*-> *) then it can be made into a type using a single type application
Kind<ForList, A>
(= List<A>). For a map, which takes 2 type arguments we need to apply it twice. Which means we can also "curry" it into a type which only needs 1 type argument, for example we could already apply the type argument of the keys.
Kind<ForMap, String>
and now this type fits all maps that have
Map<String,?>
. Which is the same shape as
List
(* -> *), and you can use it in the same way with typeclasses such as
Functor
or
Traverse
.
And by telling the compiler that
Kind<F, A>
is the same as
F<A>
, we can eliminate
fix
from the code. We can do so with compiler plugins.