Expression Evaluator

Actions Build Scala Steward Maven Central

Compile-time expression evaluation for Scala

How to use

Add the library with a "provided" scope to your dependencies list:

libraryDependencies ++= Seq(
  "com.github.plokhotnyuk.expression-evaluator" %% "expression-evaluator" % "0.1.3" % Provided // required only in compile-time

Generate expression results for primitives, strings, BigInt, java.time.ZoneId, java.time.ZoneOffset, and arrays of them:

import com.github.plokhotnyuk.expression_evaluator._

object Constants {
  val x = eval(10 * 10 * 10)
  val xs = eval((1 to 3).toArray)

To see generated code for expression results

scalacOptions ++= Seq("-Xmacro-settings:print-expr-results")

How to contribute

Build and test

To compile, run tests, check coverage, and check binary compatibility for different Scala versions use a command:

sbt clean +coverage +test +coverageReport +mimaReportBinaryIssues

BEWARE: expression-evaluator is included into Scala Community Build for 2.11.x, 2.12.x, and 2.13.x versions of Scala.

Publish locally

Publish to the local Ivy repo:

sbt +publishLocal

Publish to the local Maven repo:

sbt +publishM2


For version numbering use Recommended Versioning Scheme that is used in the Scala ecosystem.

Double check binary and source compatibility (including behavior) and run release command (credentials required):

sbt release