The REPL application also provides commands `test` and `testAll` for
running scenarios in packages:
$ bazel run //:daml-lf-repl -- testAll $PWD/project.dalf
$ bazel run //:daml-lf-repl -- test Project.tests $PWD/project.dalf
NOTE: When running via `bazel run` one needs to specify full path (or relative path from repo root), since Bazel runs all commands from repository root.
Scala house rules
-----------------
* _Do not_ use `Seq` in the interpreter's code paths, with the possible
exceptions of accepting inputs in external APIs. Use `ImmArray`,
`FrontStack`, and `BackStack` as appropriate.
The reason for this rule is that `Seq` hides completely the
performance of operations -- for example it defines cons and snoc
and append for all structures even if it requires a full copy for an
array.
`ImmArray` should be used in cases where you do not need to append
or prepend content often. It is however very cheap to slice the
`ImmArray` (removing elements from either end).
`FrontStack` should be used when needing to build up a list of
elements by prepending elements. Both single elements or chunks
in the form of `ImmArray` can be prepended. A typical use case
if traversing a tree in topological order by keeping a stack of
children to still be visited.
`BackStack` is like `FrontStack` but you can append rather than
prepend. For example if you find yourself building and then
reversing a list, use `BackStack` instead.
* Avoid mutable data structures in external APIs. This is not set in
stone but generally a code smell.
* Try to always define functions on user-provided data structures (of
which we have a lot of in this codebase) to be tail recursive. The
typical way to do this is by defining little "interpreters" to perform
your function. XXX put good example here once we have an established
pattern. In doubt, ask Francesco Mazzoli or Gyorgy Farkas about this.
* Disable "Optimize imports on the fly" and the "Optimize Imports" shortcut in
IntelliJ IDEA, since they mess up diffs and can subtly, insidiously change
the semantics of your code (Scala imports are order sensitive). You can
disable "on the fly" at Menu -> Preferences -> Editor -> General -> Auto
Import -> Scala, and the shortcut key in Preferences -> Keymap -> search
Optimize Imports -> double-click result -> Remove.