Scalaz迭代:“提升”`EnumeratorT`以匹配`IterateeT`为“更大”的monad

本文翻译自:Scalaz iteratees: “Lifting” `EnumeratorT` to match `IterateeT` for a “bigger” monad

If I have an EnumeratorT and a corresponding IterateeT I can run them together: 如果我有一个EnumeratorT和一个相应的IterateeT我可以一起运行它们:

val en: EnumeratorT[String, Task] = EnumeratorT.enumList(List("a", "b", "c"))
val it: IterateeT[String, Task, Int] = IterateeT.length

(it &= en).run : Task[Int]

If the enumerator monad is "bigger" than the iteratee monad, I can use up or, more generally, Hoist to "lift" the iteratee to match: 如果枚举器monad比iteratee monad“更大”,我可以用up或者更常见的是,使用Hoist “提升”iteratee以匹配:

val en: EnumeratorT[String, Task] = ...
val it: IterateeT[String, Id, Int] = ...

val liftedIt = IterateeT.IterateeTMonadTrans[String].hoist(
  implicitly[Task |>=| Id]).apply(it)
(liftedIt &= en).run: Task[Int]

But what do I do when the iteratee monad is "bigger" than the enumerator monad? 但是当iteratee monad比枚举器monad“更大”时,我该怎么办?

val en: EnumeratorT[String, Id] = ...
val it: IterateeT[String, Task, Int] = ...

it &= ???

There doesn't seem to be a Hoist instance for EnumeratorT , nor any obvious "lift" method. 似乎没有EnumeratorTHoist实例,也没有任何明显的“提升”方法。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值