All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.arrow.optics.dsl.index.kt Maven / Gradle / Ivy

There is a newer version: 2.0.1-alpha.1
Show newest version
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