importjapgolly.scalagraal._// Use semantics and implicit config for JS// (GraalVM also supports Python, R, Ruby, LLVM)importjapgolly.scalagraal.js._importGraalJs._// 1. Pre-compile expression functions for fast invocation.// 2. Typeclasses translate and/or marshall data between JVM and JS.valexpr: (Int, Int) =>Expr[String] =Expr.apply2((a, b) =>s"($a + $b) * 2 + '!'").compile(_.asString)
// Use a basic synchronous JS environmentvalctx=GraalContext()
valresult= ctx.eval(expr(3, 8))
assert(result ==Right("22!"))