Skip to content

Instantly share code, notes, and snippets.

@ahoy-jon
Created November 12, 2024 14:04
Show Gist options
  • Save ahoy-jon/0bb3b3bec0211cd203ec2519c7e608b7 to your computer and use it in GitHub Desktop.
Save ahoy-jon/0bb3b3bec0211cd203ec2519c7e608b7 to your computer and use it in GitHub Desktop.
import scala.annotation.{ nowarn, tailrec }
import kyo.*
val a = 1
def doSomething(): Unit = {
println("do")
println("something")
}
object inKyo {
val doSomething: Unit < IO = IO({
println("do")
println("something")
})
}
trait Impure
object usingImpure {
def doSomething(
using
Impure
): Unit = {
println("do")
println("something")
}
val x: Impure ?=> Unit = doSomething
}
def doSomethingElse(n: Int): Unit = {
(0 until n).foreach(_ => doSomething())
}
def call(): Unit = doSomethingElse(3)
@nowarn // @effect
def factorial(n: Int): Int = {
if (n == 0) 1
else n * factorial(n - 1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment