By Alvin Alexander. Last updated: December 9, 2023
As a brief note to self, when you need to reduce the Scala Ammonite REPL verbosity, specifically the output that shows “type” information when you declare new variables, I just found that this command helps:
repl.pprinter() = repl.pprinter().copy(defaultHeight = 0)
From what I can tell from the docs, the defaultHeight
defaults to 5
, and this reduces it to 0
. So when you have Ammonite type output that looks like res1
in this example:
amm> case class Person(firstName: String, lastName: String, age: Int) defined class Person amm> Person("Fred", "Flintstone", 30) res1: Person = Person(firstName = "Fred", lastName = "Flintstone", age = 30)
You can then run this command:
repl.pprinter() = repl.pprinter().copy(defaultHeight = 0)
and then the Ammonite output is truncated to this:
amm> Person("Fred", "Flintstone", 30) ......
That might not seem like a huge win for a little example like this, but when you’re doing more complicated things (such as with ZIO or Cats Effect) and don’t want to see that type output, it sure does help.