Skip to content

Commit

Permalink
Update dependencies and add optics example (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
chiroptical authored Apr 21, 2023
1 parent 41a9664 commit 44c909c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
37 changes: 25 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
kotlin("multiplatform") version "1.6.21" apply true
id("io.kotest.multiplatform") version "5.3.0" apply true
kotlin("multiplatform") version "1.8.20" apply true
id("io.kotest.multiplatform") version "5.5.4" apply true
id("com.google.devtools.ksp") version "1.8.20-1.0.11"
}

group "org.example"
Expand All @@ -13,6 +14,12 @@ repositories {
}
}

// release candidate avoids a null pointer exception during optics generation
val arrowVersion = "1.2.0-RC"
dependencies {
add("kspCommonMainMetadata", "io.arrow-kt:arrow-optics-ksp-plugin:$arrowVersion")
}

kotlin {
jvm()

Expand Down Expand Up @@ -43,22 +50,26 @@ kotlin {
sourceSets {
commonMain {
dependencies {
kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin")
implementation(kotlin("stdlib-common"))
implementation("io.arrow-kt:arrow-core:1.1.3-alpha.39")
implementation("io.arrow-kt:arrow-optics:1.1.3-alpha.39")
implementation("io.arrow-kt:arrow-fx-coroutines:1.1.3-alpha.39")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1")
implementation("io.arrow-kt:arrow-core:$arrowVersion")
implementation("io.arrow-kt:arrow-optics:$arrowVersion")
implementation("io.arrow-kt:arrow-fx-coroutines:$arrowVersion")
implementation("io.arrow-kt:arrow-optics:$arrowVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
}
}

val kotestVersion = "5.5.4"
val kotestArrowVersion = "1.3.0"
commonTest {
dependencies {
implementation("io.kotest:kotest-property:5.3.0")
implementation("io.kotest:kotest-framework-engine:5.3.0")
implementation("io.kotest:kotest-assertions-core:5.3.0")
implementation("io.kotest.extensions:kotest-assertions-arrow:1.2.5")
implementation("io.kotest.extensions:kotest-property-arrow:1.2.5") // optional
implementation("io.kotest.extensions:kotest-property-arrow-optics:1.2.5") // optional
implementation("io.kotest:kotest-property:$kotestVersion")
implementation("io.kotest:kotest-framework-engine:$kotestVersion")
implementation("io.kotest:kotest-assertions-core:$kotestVersion")
implementation("io.kotest.extensions:kotest-assertions-arrow:$kotestArrowVersion")
implementation("io.kotest.extensions:kotest-property-arrow:$kotestArrowVersion") // optional
implementation("io.kotest.extensions:kotest-property-arrow-optics:$kotestArrowVersion") // optional
}
}

Expand All @@ -67,5 +78,7 @@ kotlin {
implementation("io.kotest:kotest-runner-junit5-jvm:5.3.0")
}
}

val jvmMain by getting
}
}
8 changes: 7 additions & 1 deletion src/commonMain/kotlin/example.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import arrow.core.Either
import arrow.core.Either.Left
import arrow.core.Either.Right
import arrow.core.continuations.either
import arrow.core.raise.either
import arrow.optics.optics

object Lettuce
object Knife
Expand Down Expand Up @@ -35,3 +36,8 @@ suspend fun prepareLunch(): Either<CookingException, Salad> =
val lunch = prepare(knife, lettuce).bind()
lunch
}

@optics
data class Ingredient(val name: String) {
companion object
}
2 changes: 2 additions & 0 deletions src/jvmMain/kotlin/UseIngredient.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
val lettuce = Ingredient("lettuce")
val arugula = Ingredient.name.modify(lettuce) { "arugula" }

0 comments on commit 44c909c

Please sign in to comment.