简体   繁体   English

什么是Scalaz的Tower [A]和IvoryTower?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM