Suppress return types in sbt / Scala REPL console

I remember that there is a switch somewhere to suppress printing of return types in Scala REPL, but I cannot find it. I am particularly interested in adding this switch to the sbt build file. Something like returnTypes in console := false .

eg. now I have

 scala> within( Span( 0, 33 )) res7: scala.collection.immutable.IndexedSeq[(de.sciss.lucre.expr.SpanLike, scala.collection.immutable.IndexedSeq[(de.sciss.lucre.expr.Expr[de.sciss.lucre.stm.InMemory,de.sciss.lucre.expr.SpanLike], de.sciss.lucre.expr.Expr[de.sciss.lucre.stm.InMemory,Long])])] = Vector() 

and for obvious reasons I want

 scala> within( Span( 0, 33 )) res7: Vector() 
+6
source share
1 answer

My question mainly reflects this mailing list issue . Based on the idea of ​​Rex Kerr, in build.sbt you can go to build.sbt :

 initialCommands in console := """// helper method to disable type printing def shortresults[T](t: => T) = { val s = t.toString val name = s.takeWhile(_ != ':') val idx = s.indexOf(" = ") val full = if (idx >= 0) name + s.substring(idx) else s val short = if (full.length>799) full.substring(0,796)+"..." else full print(short) t } """ 

But, unfortunately, when starting and starting the console, you must run the following three REPL return commands:

 :power :wrap shortresults :silent 
+5
source

Source: https://habr.com/ru/post/918251/


All Articles