Scott Christopher
01/07/2020, 9:11 AMinterface 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:
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)
}
raulraja
01/07/2020, 12:20 PMraulraja
01/07/2020, 12:26 PMJannis
01/07/2020, 11:36 PMKind2<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,Scott Christopher
01/08/2020, 10:05 AMProfunctor
can't extend Functor<Kind<F, A>>
without knowing something about A
Jannis
01/08/2020, 10:32 AM