commonMain.arrow.optics.dsl.index.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of arrow-optics-jvm Show documentation
Show all versions of arrow-optics-jvm Show documentation
Functional companion to Kotlin's Standard Library
package arrow.optics.dsl
import arrow.optics.Fold
import arrow.optics.Iso
import arrow.optics.Lens
import arrow.optics.Optional
import arrow.optics.Prism
import arrow.optics.Setter
import arrow.optics.Traversal
import arrow.optics.typeclasses.Index
/**
* DSL to compose [Index] with a [Lens] for a structure [S] to focus in on [A] at given index [I]
*
* @receiver [Lens] with a focus in [S]
* @param ID [Index] instance to provide a [Optional] to focus into [S] at [I]
* @param i index [I] to focus into [S] and find focus [A]
* @return [Optional] with a focus in [A] at given index [I]
*/
public fun Lens.index(ID: Index, i: I): Optional = this.compose(ID.index(i))
/**
* DSL to compose [Index] with an [Iso] for a structure [S] to focus in on [A] at given index [I]
*
* @receiver [Iso] with a focus in [S]
* @param ID [Index] instance to provide a [Optional] to focus into [S] at [I]
* @param i index [I] to focus into [S] and find focus [A]
* @return [Optional] with a focus in [A] at given index [I]
*/
public fun Iso.index(ID: Index, i: I): Optional = this.compose(ID.index(i))
/**
* DSL to compose [Index] with a [Prism] for a structure [S] to focus in on [A] at given index [I]
*
* @receiver [Prism] with a focus in [S]
* @param ID [Index] instance to provide a [Optional] to focus into [S] at [I]
* @param i index [I] to focus into [S] and find focus [A]
* @return [Optional] with a focus in [A] at given index [I]
*/
public fun Prism.index(ID: Index, i: I): Optional = this.compose(ID.index(i))
/**
* DSL to compose [Index] with an [Optional] for a structure [S] to focus in on [A] at given index [I]
*
* @receiver [Optional] with a focus in [S]
* @param ID [Index] instance to provide a [Optional] to focus into [S] at [I]
* @param i index [I] to focus into [S] and find focus [A]
* @return [Optional] with a focus in [A] at given index [I]
*/
public fun Optional.index(ID: Index, i: I): Optional = this.compose(ID.index(i))
/**
* DSL to compose [Index] with a [Setter] for a structure [S] to focus in on [A] at given index [I]
*
* @receiver [Setter] with a focus in [S]
* @param ID [Index] instance to provide a [Optional] to focus into [S] at [I]
* @param i index [I] to focus into [S] and find focus [A]
* @return [Setter] with a focus in [A] at given index [I].
*/
public fun Setter.index(ID: Index, i: I): Setter = this.compose(ID.index(i))
/**
* DSL to compose [Index] with a [Traversal] for a structure [S] to focus in on [A] at given index [I]
*
* @receiver [Traversal] with a focus in [S]
* @param ID [Index] instance to provide a [Optional] to focus into [S] at [I]
* @param i index [I] to focus into [S] and find focus [A]
* @return [Traversal] with a focus in [A] at given index [I].
*/
public fun Traversal.index(ID: Index, i: I): Traversal = this.compose(ID.index(i))
/**
* DSL to compose [Index] with a [Fold] for a structure [S] to focus in on [A] at given index [I]
*
* @receiver [Fold] with a focus in [S]
* @param ID [Index] instance to provide a [Optional] to focus into [S] at [I]
* @param i index [I] to focus into [S] and find focus [A]
* @return [Fold] with a focus in [A] at given index [I].
*/
public fun Fold.index(ID: Index, i: I): Fold = this.compose(ID.index(i))
© 2015 - 2025 Weber Informatics LLC | Privacy Policy