trait Cohoist[F[_[_], _]] extends ComonadTrans[F] {
def cohoist[M[_], N[_]: Comonad](f: M ~> N): F[M, ?] ~> F[N, ?]
}
where ComonadTrans is defined:
trait ComonadTrans[F[_[_], _]] {
def lower[G[_]: Cobind, A](a: F[G, A]): G[A]
}
The question is how to treat this type? Can someone give an explanation in a few words or give an example?
ComonadTransisn't really important to understandingcohoist, which is similar to a higher-order version of map.mapcan be reformulated, by flipping the arguments around, asIn other words it lifts a function into
F.~>is justWith that you can expand the signature of
cohoist(the two
As cannot be combined and pulled to the initial tparam list; I don't want to go into detail here beyond saying "that would not work")So just like map, it lifts a function (M to N transformer) into
F, making an "F of M" to "F of N" transformer.