Joheinz
unread,Feb 6, 2016, 6:36:15 AM2/6/16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sca...@googlegroups.com
Hi *,
I can't find a function I am looking for, but can't believe it exists.
Let's say I have a Kleisli Arrow:
val foo = kleisli[Future, Int, String] { id =>
Future.successful(s"hello ${id}") }
I can tranform this into a
1) Kleisli[OptionT[Future, ?], Int, String] by using
foo.liftMK[OptionT]
But let's say my original foo would be
val foo = kleisli[Future, Int, Option[String]] { id =>
Future.successful(s"hello ${id}".some) }
and I want to transform this into something similiar as 1) How can I
do that? I also tried to write such a function, but I fail in getting
the evidence that the type parameter B of the Kleisli needs to be
something of N[_], where N is a Monad and then get a generic
MonadTransformer
The closest I achieved was a specialised version for OptionT:
implicit class KleisiTX[M[_], A, B](k: Kleisli[M, A, Option[B]]) {
def liftOptionT(implicit M: Monad[M]): Kleisli[OptionT[M, ?], A,
B] = Kleisli[OptionT[M, ?], A, B] {
(a: A) => OptionT[M, B](k.run(a))
}
}
However, I am still somehow convinced that such a function should already exist.
Regards
Markus