Following takes care of the cases that came to mind:
def show(obj: Any) : String = {
obj match {
case o: Option[_] =>
if (o == None) {
"<none>"
} else {
show(o.get)
}
case i: Iterable[_] =>
i.map(show).mkString("[", ",", "]")
case m: Map[_, _] =>
m.map {
case (a, b) => List(show(a), show(b)).mkString(":")
}.mkString("{", ",", "}")
case e: Enumeration =>
e.toString
case c : Product if !c.getClass.getMethods.map(_.getName).contains("copy$default$2") =>
c.toString
case t: Product =>
t.productIterator.map(a => show(a)).mkString("(", ",", ")")
case _ =>
if (obj.isInstanceOf[AnyRef])
obj.asInstanceOf[AnyRef].toString
else
"" + obj
}
}
I opted to code this up to avoid adding scalaz dependency (assuming their Show class supports similar feature)