Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

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]?

like image 608
ZhekaKozlov Avatar asked Mar 26 '15 09:03

ZhekaKozlov


1 Answers

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 .

like image 191
lmm Avatar answered Sep 22 '22 11:09

lmm