arrow.data.Const.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of arrow-data Show documentation
Show all versions of arrow-data Show documentation
Functional Datatypes and abstractions for Kotlin inspired by Cats.
package arrow.data
import arrow.*
import arrow.core.Option
import arrow.typeclasses.Applicative
import arrow.typeclasses.Semigroup
fun ConstKind.value(): A = this.ev().value
@higherkind data class Const(val value: A) : ConstKind {
@Suppress("UNCHECKED_CAST")
fun retag(): Const = this as Const
fun traverse(f: (T) -> HK, FA: Applicative): HK> = FA.pure(retag())
fun traverseFilter(f: (T) -> HK>, FA: Applicative): HK> = FA.pure(retag())
companion object {
fun pure(a: A): Const = Const(a)
}
}
fun ConstKind.combine(that: ConstKind, SG: Semigroup): Const = Const(SG.combine(this.value(), that.value()))
fun ConstKind.ap(ff: ConstKind U>, SG: Semigroup): Const = ff.ev().retag().combine(this.ev().retag(), SG)
fun A.const(): Const = Const(this)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy