What are Tower[A] and IvoryTower in Scalaz?
Asked Answered
A

1

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

Anesthesia answered 26/3, 2015 at 9:28 Comment(1)
I too wish Scalaz were documented.Yabber
F
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 .

Forsworn answered 26/3, 2015 at 10:16 Comment(2)
Why is it called IvoryTower? Why not FunnyBanana or IntrepidTiger?Anesthesia
Because an ivory tower is supposed to be the opposite of the real world. google.com/search?q=define%3Aivory%20towerForsworn

© 2022 - 2024 — McMap. All rights reserved.