Curious whether it would make sense or not to add ...
# arrow
s
Curious whether it would make sense or not to add type arguments of the typeclasses to their interface, e.g.
Copy code
interface Functor<F, A> {
  fun <B> Kind<F, A>.map(f: (A) -> B): Kind<F, B>
}
The reason I ask is that I went to update the
Profunctor
interface to extend
Functor
and provide the default implementation for
map
using
rmap
, though the only way I could make the types line up was to update
Functor<F>
to
Functor<Kind<F, A>, B>
like so:
Copy code
interface Profunctor<F, A, B> : Functor<Kind<F, A>, B> {
    fun <C, D> Kind2<F, A, B>.dimap(fl: (C) -> A, fr: (B) -> D): Kind2<F, C, D>
    fun <C> Kind2<F, A, B>.lmap(f: (C) -> A): Kind2<F, C, B> = dimap(f, ::identity)
    fun <C> Kind2<F, A, B>.rmap(f: (B) -> C): Kind2<F, A, C> = dimap(::identity, f)
    override fun <C> Kind<Kind<F, A>, B>.map(f: (B) -> C): Kind<Kind<F, A>, C> = rmap(f)
}
r
we tried this encoding and also has its shortcomings
It will be there around April when type proofs are finished
j
Btw not sure you are aware of this or even still need it but
Kind2<F, A, B> == Kind<Kind<F, A>, B>
so
Functor<Kind<F, A>>
will leave you with
<B, C> Kind<Kind<F, A>, B>.map(f: (B) -> C): Kind<Kind<F, A>, C>
which is exactly what you need,
s
That was what lead me down the path to adding the extra type arguments to the typeclasses, because
Profunctor
can't extend
Functor<Kind<F, A>>
without knowing something about
A
j
Right, forgot 👍 So the only way is to have a method return an instance...