2

A single of code can achieve a lot in Scala.

def -(that: Nat) = if (that.isZero) this else throw new Error("negative number")

However, it is difficult to debug. Any tips?

om-nom-nom
  • 62,329
  • 13
  • 183
  • 228
More Than Five
  • 9,959
  • 21
  • 77
  • 127

2 Answers2

4

Use scala worksheet. That's it: you'll get multiline REPL with your environment in which you can play with your code.

enter image description here Alternatively, just use REPL bundled with sbt (sbt console) with proper imports

om-nom-nom
  • 62,329
  • 13
  • 183
  • 228
-1

you can see output of compiler phases, i.e. the AST after desugarings with

scalac -Xprint:typer

scalac -Xprint-types (note hyphen, not colon)

The man page is a little confusing, there's no "typer" phase listed, but it works:

http://www.scala-lang.org/docu/files/tools/scalac.html

Compile time type tracing

Community
  • 1
  • 1
Gene T
  • 5,156
  • 1
  • 24
  • 24