This is the second of a series of articles on “Monadic EDSLs in Scala.” Perhaps the most direct way to start writing an EDSL is to start writing functions. Let’s say we want a language for talking about sets of integers. trait SetLang { def add(i: Int, set: Set[Int]): Set[Int] def remove(i: Int, set: Set[Int]): Set[Int] def exists(i: Int, set: Set[Int]): Boolean } This works… to the extent that we want only to work with scala.collection.Sets. As it stands we cannot talk about other se...