[英]What are Tower[A] and IvoryTower in Scalaz?
When I looked at scalaz.effect.IO
source code, I noticed that it has a method apply
with the following signature: 当我查看
scalaz.effect.IO
源代码时,我注意到它有一个方法apply
于以下签名:
sealed trait IO[A] {
def apply(rw: Tower[IvoryTower]): Trampoline[(Tower[IvoryTower], A)]
}
Tower[A]
and IvoryTower
are defined as: Tower[A]
和IvoryTower
定义为:
case class Tower[A]()
sealed trait IvoryTower
There is one instance of Tower
: Tower
有一个例子:
object IvoryTower extends IvoryTowers
trait IvoryTowers {
val ivoryTower = Tower[IvoryTower]()
}
What is the purpose of these classes? 这些课程的目的是什么? Why does
IO.apply
accepts an argument of type Tower[IvoryTower]
? 为什么
IO.apply
接受Tower[IvoryTower]
类型的参数?
It's an in-joke: IvoryTower
is a port of a Haskell type called RealWorld
. 这是一个玩笑:
IvoryTower
是一个名为RealWorld
的Haskell类型的端口。 (I do wish it had a clearer name - this one manages to be both impenetrable to newcomers and not actually funny). (我确实希望它有一个更清晰的名字 - 这个名字对新手来说既难以穿透,又实际上并不好笑)。 See eg https://wiki.haskell.org/IO_inside .
参见例如https://wiki.haskell.org/IO_inside 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.