
jvmMain.io.kotest.assertions.arrow.prelude.kt Maven / Gradle / Ivy
package io.kotest.assertions.arrow
import arrow.Kind
import arrow.typeclasses.ApplicativeError
import io.kotest.matchers.Matcher
import io.kotest.matchers.MatcherResult
import kotlin.random.Random
internal fun matcher(
passed: Boolean,
msg: String,
negatedFailureMsg: String = msg
): Matcher =
object : Matcher {
override fun test(value: A): MatcherResult = MatcherResult(passed, msg, negatedFailureMsg)
}
/**
* Polymorphic chooser that distributes generation of arbitrary higher kinded values
* where [F] provides extensions for the [ApplicativeError] interface.
* The chooser dispatches returns an error or value in the context of [F]
*/
fun ApplicativeError.choose(fe: () -> E, fa: () -> A): Kind =
if (Random.nextBoolean()) raiseError(fe()) else just(fa())
© 2015 - 2025 Weber Informatics LLC | Privacy Policy