9

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

ZhekaKozlov
  • 36,558
  • 20
  • 126
  • 155

1 Answers1

8

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 .

lmm
  • 17,386
  • 3
  • 26
  • 37
  • Why is it called IvoryTower? Why not FunnyBanana or IntrepidTiger? – ZhekaKozlov Mar 27 '15 at 07:45
  • 1
    Because an ivory tower is supposed to be the opposite of the real world. https://www.google.com/search?q=define%3Aivory%20tower – lmm Mar 27 '15 at 10:58