julianpeeters / dc10-cats-effect   0.2.1

Apache License 2.0 GitHub

Library for use with the `dc10-scala` code generator

Scala versions: 3.x
Scala.js versions: 1.x
Scala Native versions: 0.4

dc10-cats-effect

Library for use with the dc10-scala code generator

Getting Started

  • Library for Scala 3.4+ (JS, JVM, and Native platforms)
"com.julianpeeters" %% "dc10-cats-effect" % "0.2.1"

Usage

Use the dsl to define scala code that depends on cats-effect:

import dc10.cats.effect.dsl.*
import dc10.scala.dsl.given               // for strings, e.g., "Hello, World!"
import scala.language.implicitConversions // for literals, e.g., "Hello, World!"

val snippet =
  IOAPP("HelloWorld",
    RUN(
      IO.PRINTLN("Hello, World!")
    )
  )
// snippet: IndexedStateT[ErrorF, List[Statement], List[Statement], ValueExpr[IO[Unit], Tuple2[Unit, Unit]]] = cats.data.IndexedStateT@5e21b627

Use the compiler in dc10-scala to render code toString or toVirtualFile:

import dc10.scala.compiler.{compile, toString}
import dc10.scala.version.`3.4.0`

val result: String = snippet.compile.toString["scala-3.4.0"]
// result: String = """object HelloWorld extends cats.effect.IOApp.Simple:
// 
//   val run: cats.effect.IO[Unit] = cats.effect.IO.println("Hello, World!")"""