Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eed3si9n/eval
Eval evaluates Scala 3 code. Why parse JSON when you can load case classes?
https://github.com/eed3si9n/eval
Last synced: 15 days ago
JSON representation
Eval evaluates Scala 3 code. Why parse JSON when you can load case classes?
- Host: GitHub
- URL: https://github.com/eed3si9n/eval
- Owner: eed3si9n
- Created: 2022-03-28T05:37:30.000Z (over 2 years ago)
- Default Branch: develop
- Last Pushed: 2024-03-11T16:44:03.000Z (8 months ago)
- Last Synced: 2024-10-04T15:25:04.285Z (about 1 month ago)
- Language: Scala
- Homepage: https://eed3si9n.com/eval/
- Size: 20.5 KB
- Stars: 16
- Watchers: 4
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Eval
====Eval evaluates Scala 3 code.
Example Usage
=============In your `build.sbt` type this or similar:
```scala
ThisBuild / scalaVersion := "3.3.1"
libraryDependencies += ("com.eed3si9n.eval" % "eval" % "0.3.0").cross(CrossVersion.full)
Compile / fork := true
```In your `Main.scala` type this or similar:
```scala
package exampleimport com.eed3si9n.eval.Eval
case class ServerConfig(port: Int)
@main def main(): Unit =
val x = Eval[ServerConfig](
"example.ServerConfig(port = 8080)")
println(x.port)
```Run in `sbt` like so:
```
sbt:eval> run
[info] compiling 1 Scala source to target/scala-3.3.1/classes ...
[info] running (fork) example.main
[info] 8080
```This shows that the string example.ServerConfig(port = 8080) was evaluated as a Scala code,
and became available to the main function as an instantiated case class.More examples here: https://eed3si9n.com/eval/