A Definitional Compiler for generating Scala code.
- Library for Scala 3 (JS, JVM, and Native platforms)
- Generates code for Scala 3
"com.julianpeeters" %% "dc10-scala" % "0.9.0"
Use the dsl
to define Scala code (see available libraries):
import dc10.scala.dsl.{*, given}
import scala.language.implicitConversions // for literals, e.g. "hello, world"
val snippet =
for
s <- VAL("str", STRING) := "hello, world"
_ <- VAL("msg", STRING) := s
yield ()
// snippet: IndexedStateT[ErrorF, Tuple2[Set[LibDep], List[Statement]], Tuple2[Set[LibDep], List[Statement]], Unit] = cats.data.IndexedStateT@7dba5996
Use the compiler
impl to check and render code to string
or virtualFile
:
import dc10.scala.compiler.{compile, string}
import dc10.scala.version.`3.5.2`
val result: String = snippet.compile.string
// result: String = """val str: String = "hello, world"
// val msg: String = str"""