When I looked at scalaz.effect.IO
source code, I noticed that it has a method apply
with the following signature:
sealed trait IO[A] {
def apply(rw: Tower[IvoryTower]): Trampoline[(Tower[IvoryTower], A)]
}
Tower[A]
and IvoryTower
are defined as:
case class Tower[A]()
sealed trait IvoryTower
There is one instance of 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]
?
It's an in-joke: IvoryTower
is a port of a Haskell type called RealWorld
. (I do wish it had a clearer name - this one manages to be both impenetrable to newcomers and not actually funny). See e.g. https://wiki.haskell.org/IO_inside .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With