-
Install Scala CLI - most likely with
brew install Virtuslab/scala-cli/scala-cli -
Create a project with library (
greet.scalaand appgreeter.sc)
greet.scala:
def greet(name: String) = s"Hello, $name!"Install Scala CLI - most likely with brew install Virtuslab/scala-cli/scala-cli
Create a project with library (greet.scala and app greeter.sc)
greet.scala:
def greet(name: String) = s"Hello, $name!"| val numbers = Seq(1,2,3,5,7,42) |
| { | |
| "scala-cli-sip": { | |
| "repositories": [ | |
| "central" | |
| ], | |
| "name": "scala-cli-sip", | |
| "dependencies": [ | |
| "org.virtuslab.scala-cli:cli_3:latest.release" | |
| ], | |
| "launcherType": "graalvm-native-image", |
| // using scala 3.0.2 | |
| // using lib org.apache.spark:spark-sql_2.13:3.2.0 | |
| // using repository https://wip-repos.s3.eu-central-1.amazonaws.com/.release | |
| // using lib io.github.vincenzobaz::spark-scala3:0.1.3-new-spark | |
| import scala3encoders.given | |
| import org.apache.spark.sql.Dataset | |
| import org.apache.spark.sql.SparkSession |
| // using scala 3 | |
| // using repository https://repository.apache.org/content/repositories/staging | |
| // using org.apache.spark:spark-sql_2.13:3.2.0 | |
| // using repository https://wip-repos.s3.eu-central-1.amazonaws.com/.release | |
| // using io.github.vincenzobaz::spark-scala3:0.1.3-new-spark | |
| // using org.scala-lang::scala3-tasty-inspector:3.0.2 | |
| // using "io.get-coursier:coursier_2.13:2.0.16-169-g194ebc55c" |
| object ScalaVersion extends App { | |
| def props(url: java.net.URL): java.util.Properties = { | |
| val properties = new java.util.Properties() | |
| val is = url.openStream() | |
| try { | |
| properties.load(is) | |
| properties | |
| } finally is.close() | |
| } |
The mechanism to define tests in scala-cli should cover following usecases:
config.scala)We've considered many ways how we can achieve that with @using directives however this introduced following problems:
@using directictives content applies to the whole compilation unit but in case of tests we want to apply it to the current file. We can workaround this using following syntax @using tests.from thisFile or similar but it feels not natural and ovious.Our proposal is to create another directive called @target that will define contraints about target that this files applies to. We think that target should be define before any @usin
| class PlayerTraits(str : Int, dex : Int, wis : Int) { | |
| @CompilerControl(DONT_INLINE) def strCost: Int = str | |
| @CompilerControl(DONT_INLINE) def dexCost: Int = dex | |
| @CompilerControl(DONT_INLINE) def wisCost: Int = wis | |
| } |
| trait Mapper[A, B]{ | |
| def map(a: Rep[B]): Rep[Option[A]] | |
| } | |
| object Mapper { | |
| implicit def plain[A: BaseTypedType] = new Mapper[A, A] { override def map(a: Rep[A]) = a.?} | |
| implicit def option[A] = new Mapper[A, Option[A]] { override def map(a: Rep[Option[A]]) = a} | |
| } | |
| trait Optionable[A]{ | |
| type M[Original] = Mapper[A, Original] | |
| } |
| package object lib { | |
| // When we make RicherString implicit class Foo won't compile | |
| class RicherString(base: String) { | |
| val head: Char = if(base.isEmpty) ' ' else base.charAt(0) | |
| } | |
| } |