【发布时间】:2016-04-12 18:13:00
【问题描述】:
因为我想结合Kleisli 可以在可能失败Future 的长方法Either 上工作,所以我需要堆叠效果。这是在 Kleisli 中堆叠效果的结果代码。 scalaz 中是否有现有的组合器?
type FutureEitherT[A] = EitherT[Future, String, A]
def toKleisliEitherTFromDisjunction[A](f: Kleisli[Future, Context,String \/ A]) =
Kleisli[FutureEitherT, Context, A] { ctx => EitherT(f(ctx)) }
我试过f.liftMK[FutureEitherT]没有成功,但不幸的是,Kleisli类型构造函数中的第三种类型仍然是Either。
【问题讨论】:
标签: scala scalaz monad-transformers