diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 81a0e2b..ef8425e 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -18,6 +18,7 @@ kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-c
arrow-fx-coroutines = { module = "io.arrow-kt:arrow-fx-coroutines", version.ref = "arrow" }
arrow-core = { module = "io.arrow-kt:arrow-core", version.ref = "arrow" }
arrow-optics = { module = "io.arrow-kt:arrow-optics", version.ref = "arrow" }
+arrow-functions = { module = "io.arrow-kt:arrow-functions", version.ref = "arrow" }
# Gradle plugins used in buildSrc
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
diff --git a/kotest-property-arrow-optics/build.gradle.kts b/kotest-property-arrow-optics/build.gradle.kts
index 2e2c456..6e0044b 100644
--- a/kotest-property-arrow-optics/build.gradle.kts
+++ b/kotest-property-arrow-optics/build.gradle.kts
@@ -7,6 +7,7 @@ kotlin {
commonMain {
dependencies {
compileOnly(libs.arrow.optics)
+ implementation(libs.arrow.functions)
implementation(libs.kotest.assertions.core)
implementation(libs.kotest.framework.api)
implementation(libs.kotest.property)
diff --git a/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/IsoLaws.kt b/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/IsoLaws.kt
index e53b7f2..035354d 100644
--- a/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/IsoLaws.kt
+++ b/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/IsoLaws.kt
@@ -2,7 +2,7 @@
package io.kotest.property.arrow.optics
-//import arrow.core.compose
+import arrow.core.compose
import arrow.core.identity
import arrow.optics.Iso
import io.kotest.property.Arb
@@ -25,7 +25,7 @@ public object IsoLaws {
Law("Iso Law: round trip one way") { iso.roundTripOneWay(aGen, eqa) },
Law("Iso Law: round trip other way") { iso.roundTripOtherWay(bGen, eqb) },
Law("Iso Law: modify identity is identity") { iso.modifyIdentity(aGen, eqa) },
-// Law("Iso Law: compose modify") { iso.composeModify(aGen, funcGen, eqa) },
+ Law("Iso Law: compose modify") { iso.composeModify(aGen, funcGen, eqa) },
Law("Iso Law: consitent set with modify") { iso.consistentSetModify(aGen, bGen, eqa) }
)
@@ -44,11 +44,11 @@ public object IsoLaws {
modify(a, ::identity).equalUnderTheLaw(a, eq)
}
-// public suspend fun Iso.composeModify(aGen: Arb, funcGen: Arb<(B) -> B>, eq: (A, A) -> Boolean): PropertyContext =
-// checkAll(aGen, funcGen, funcGen) { a, f, g ->
-// modify(modify(a, f), g).equalUnderTheLaw(modify(a, g compose f), eq)
-// }
-//
+ public suspend fun Iso.composeModify(aGen: Arb, funcGen: Arb<(B) -> B>, eq: (A, A) -> Boolean): PropertyContext =
+ checkAll(aGen, funcGen, funcGen) { a, f, g ->
+ modify(modify(a, f), g).equalUnderTheLaw(modify(a, g compose f), eq)
+ }
+
public suspend fun Iso.consistentSetModify(aGen: Arb, bGen: Arb, eq: (A, A) -> Boolean): PropertyContext =
checkAll(aGen, bGen) { a, b ->
set(b).equalUnderTheLaw(modify(a) { b }, eq)
diff --git a/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/LensLaws.kt b/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/LensLaws.kt
index 5e2796e..ac0e394 100644
--- a/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/LensLaws.kt
+++ b/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/LensLaws.kt
@@ -2,6 +2,7 @@
package io.kotest.property.arrow.optics
+import arrow.core.compose
import arrow.core.identity
import arrow.optics.Lens
import io.kotest.property.Arb
@@ -26,7 +27,7 @@ public object LensLaws {
Law("Lens law: set get") { lensSetGet(lensGen, aGen, bGen, eqb) },
Law("Lens law: is set idempotent") { lensSetIdempotent(lensGen, aGen, bGen, eqa) },
Law("Lens law: modify identity") { lensModifyIdentity(lensGen, aGen, eqa) },
-// Law("Lens law: compose modify") { lensComposeModify(lensGen, aGen, funcGen, eqa) },
+ Law("Lens law: compose modify") { lensComposeModify(lensGen, aGen, funcGen, eqa) },
Law("Lens law: consistent set modify") { lensConsistentSetModify(lensGen, aGen, bGen, eqa) }
)
@@ -84,18 +85,18 @@ public object LensLaws {
}
}
-// public suspend fun lensComposeModify(
-// lensGen: Arb>,
-// aGen: Arb,
-// funcGen: Arb<(B) -> B>,
-// eq: (A, A) -> Boolean
-// ): PropertyContext =
-// checkAll(lensGen, aGen, funcGen, funcGen) { lens, a, f, g ->
-// lens.run {
-// modify(modify(a, f), g).equalUnderTheLaw(modify(a, g compose f), eq)
-// }
-// }
-//
+ public suspend fun lensComposeModify(
+ lensGen: Arb>,
+ aGen: Arb,
+ funcGen: Arb<(B) -> B>,
+ eq: (A, A) -> Boolean
+ ): PropertyContext =
+ checkAll(lensGen, aGen, funcGen, funcGen) { lens, a, f, g ->
+ lens.run {
+ modify(modify(a, f), g).equalUnderTheLaw(modify(a, g compose f), eq)
+ }
+ }
+
public suspend fun lensConsistentSetModify(
lensGen: Arb>,
aGen: Arb,
diff --git a/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/OptionalLaws.kt b/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/OptionalLaws.kt
index 4dd1d01..254622b 100644
--- a/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/OptionalLaws.kt
+++ b/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/OptionalLaws.kt
@@ -2,6 +2,7 @@
package io.kotest.property.arrow.optics
+import arrow.core.compose
import arrow.core.identity
import arrow.optics.Optional
import io.kotest.property.Arb
@@ -25,7 +26,7 @@ public object OptionalLaws {
Law("Optional Law: set what you get") { setGetOption(optionalGen, aGen, bGen, eqb) },
Law("Optional Law: set is idempotent") { setIdempotent(optionalGen, aGen, bGen, eqa) },
Law("Optional Law: modify identity = identity") { modifyIdentity(optionalGen, aGen, eqa) },
-// Law("Optional Law: compose modify") { composeModify(optionalGen, aGen, funcGen, eqa) },
+ Law("Optional Law: compose modify") { composeModify(optionalGen, aGen, funcGen, eqa) },
Law("Optional Law: consistent set with modify") { consistentSetModify(optionalGen, aGen, bGen, eqa) }
)
@@ -88,18 +89,18 @@ public object OptionalLaws {
}
}
-// public suspend fun composeModify(
-// optionalGen: Arb>,
-// aGen: Arb,
-// funcGen: Arb<(B) -> B>,
-// eq: (A, A) -> Boolean
-// ): PropertyContext =
-// checkAll(optionalGen, aGen, funcGen, funcGen) { optional, a, f, g ->
-// optional.run {
-// modify(modify(a, f), g).equalUnderTheLaw(modify(a, g compose f), eq)
-// }
-// }
-//
+ public suspend fun composeModify(
+ optionalGen: Arb>,
+ aGen: Arb,
+ funcGen: Arb<(B) -> B>,
+ eq: (A, A) -> Boolean
+ ): PropertyContext =
+ checkAll(optionalGen, aGen, funcGen, funcGen) { optional, a, f, g ->
+ optional.run {
+ modify(modify(a, f), g).equalUnderTheLaw(modify(a, g compose f), eq)
+ }
+ }
+
public suspend fun consistentSetModify(
optionalGen: Arb>,
aGen: Arb,
diff --git a/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/PrismLaws.kt b/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/PrismLaws.kt
index 68aff43..193d7fe 100644
--- a/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/PrismLaws.kt
+++ b/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/PrismLaws.kt
@@ -2,6 +2,7 @@
package io.kotest.property.arrow.optics
+import arrow.core.compose
import arrow.core.identity
import arrow.optics.Prism
import io.kotest.property.Arb
@@ -23,7 +24,7 @@ public object PrismLaws {
Law("Prism law: partial round trip one way") { prism.partialRoundTripOneWay(aGen, eqa) },
Law("Prism law: round trip other way") { prism.roundTripOtherWay(bGen, eqb) },
Law("Prism law: modify identity") { prism.modifyIdentity(aGen, eqa) },
-// Law("Prism law: compose modify") { prism.composeModify(aGen, funcGen, eqa) },
+ Law("Prism law: compose modify") { prism.composeModify(aGen, funcGen, eqa) },
Law("Prism law: consistent set modify") { prism.consistentSetModify(aGen, bGen, eqa) }
)
@@ -44,10 +45,10 @@ public object PrismLaws {
modify(a, ::identity).equalUnderTheLaw(a, eq)
}
-// public suspend fun Prism.composeModify(aGen: Arb, funcGen: Arb<(B) -> B>, eq: (A, A) -> Boolean): PropertyContext =
-// checkAll(aGen, funcGen, funcGen) { a, f, g ->
-// modify(modify(a, f), g).equalUnderTheLaw(modify(a, g compose f), eq)
-// }
+ public suspend fun Prism.composeModify(aGen: Arb, funcGen: Arb<(B) -> B>, eq: (A, A) -> Boolean): PropertyContext =
+ checkAll(aGen, funcGen, funcGen) { a, f, g ->
+ modify(modify(a, f), g).equalUnderTheLaw(modify(a, g compose f), eq)
+ }
public suspend fun Prism.consistentSetModify(aGen: Arb, bGen: Arb, eq: (A, A) -> Boolean): PropertyContext =
checkAll(aGen, bGen) { a, b ->
diff --git a/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/TraversalLaws.kt b/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/TraversalLaws.kt
index cf95d4d..18321a3 100644
--- a/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/TraversalLaws.kt
+++ b/kotest-property-arrow-optics/src/commonMain/kotlin/io/kotest/property/arrow/optics/TraversalLaws.kt
@@ -2,7 +2,7 @@
package io.kotest.property.arrow.optics
-//import arrow.core.compose
+import arrow.core.compose
import arrow.core.identity
import arrow.optics.Traversal
import io.kotest.property.Arb
@@ -23,8 +23,7 @@ public object TraversalLaws {
): List = listOf(
Law("Traversal law: set is idempotent") { traversal.setIdempotent(aGen, bGen, eq) },
Law("Traversal law: modify identity") { traversal.modifyIdentity(aGen, eq) },
- // TODO: Was there any replacement for `compose` in Arrow 2?
-// Law("Traversal law: compose modify") { traversal.composeModify(aGen, funcGen, eq) }
+ Law("Traversal law: compose modify") { traversal.composeModify(aGen, funcGen, eq) }
)
public suspend fun Traversal.setIdempotent(aGen: Arb, bGen: Arb, eq: (A, A) -> Boolean): PropertyContext =
@@ -38,19 +37,18 @@ public object TraversalLaws {
modify(a, ::identity).equalUnderTheLaw(a, eq)
}
- // TODO: Was there any replacement for `compose` in Arrow 2?
-// public suspend fun Traversal.composeModify(
-// aGen: Arb,
-// funcGen: Arb<(B) -> B>,
-// eq: (A, A) -> Boolean
-// ): PropertyContext =
-// checkAll(
-// max(max(aGen.minIterations(), funcGen.minIterations()), funcGen.minIterations()),
-// aGen,
-// funcGen,
-// funcGen
-// ) { a, f, g ->
-// modify(modify(a, f), g)
-// .equalUnderTheLaw(modify(a, g compose f), eq)
-// }
+ public suspend fun Traversal.composeModify(
+ aGen: Arb,
+ funcGen: Arb<(B) -> B>,
+ eq: (A, A) -> Boolean
+ ): PropertyContext =
+ checkAll(
+ max(max(aGen.minIterations(), funcGen.minIterations()), funcGen.minIterations()),
+ aGen,
+ funcGen,
+ funcGen
+ ) { a, f, g ->
+ modify(modify(a, f), g)
+ .equalUnderTheLaw(modify(a, g compose f), eq)
+ }
}