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

commonMain.arrow.optics.dsl.at.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.Getter
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.At

/**
 * DSL to compose [At] with a [Lens] for a structure [S] to focus in on [A] at given index [I].
 *
 * @receiver [Lens] with a focus in [S]
 * @param AT [At] instance to provide a [Lens] to zoom into [S] at [I]
 * @param i index [I] to zoom into [S] and find focus [A]
 * @return [Lens] with a focus in [A] at given index [I].
 */
public fun  Lens.at(AT: At, i: I): Lens = this.compose(AT.at(i))

/**
 * DSL to compose [At] with an [Iso] for a structure [S] to focus in on [A] at given index [I].
 *
 * @receiver [Iso] with a focus in [S]
 * @param AT [At] instance to provide a [Lens] to zoom into [S] at [I]
 * @param i index [I] to zoom into [S] and find focus [A]
 * @return [Lens] with a focus in [A] at given index [I].
 */
public fun  Iso.at(AT: At, i: I): Lens = this.compose(AT.at(i))

/**
 * DSL to compose [At] with a [Prism] for a structure [S] to focus in on [A] at given index [I].
 *
 * @receiver [Prism] with a focus in [S]
 * @param AT [At] instance to provide a [Lens] to zoom into [S] at [I]
 * @param i index [I] to zoom into [S] and find focus [A]
 * @return [Optional] with a focus in [A] at given index [I].
 */
public fun  Prism.at(AT: At, i: I): Optional = this.compose(AT.at(i))

/**
 * DSL to compose [At] with an [Optional] for a structure [S] to focus in on [A] at given index [I].
 *
 * @receiver [Optional] with a focus in [S]
 * @param AT [At] instance to provide a [Lens] to zoom into [S] at [I]
 * @param i index [I] to zoom into [S] and find focus [A]
 * @return [Optional] with a focus in [A] at given index [I].
 */
public fun  Optional.at(AT: At, i: I): Optional = this.compose(AT.at(i))

/**
 * DSL to compose [At] with a [Getter] for a structure [S] to focus in on [A] at given index [I].
 *
 * @receiver [Getter] with a focus in [S]
 * @param AT [At] instance to provide a [Lens] to zoom into [S] at [I]
 * @param i index [I] to zoom into [S] and find focus [A]
 * @return [Getter] with a focus in [A] at given index [I].
 */
public fun  Getter.at(AT: At, i: I): Getter = this.compose(AT.at(i))

/**
 * DSL to compose [At] with a [Setter] for a structure [S] to focus in on [A] at given index [I].
 *
 * @receiver [Setter] with a focus in [S]
 * @param AT [At] instance to provide a [Lens] to zoom into [S] at [I]
 * @param i index [I] to zoom into [S] and find focus [A]
 * @return [Setter] with a focus in [A] at given index [I].
 */
public fun  Setter.at(AT: At, i: I): Setter = this.compose(AT.at(i))

/**
 * DSL to compose [At] with a [Traversal] for a structure [S] to focus in on [A] at given index [I].
 *
 * @receiver [Traversal] with a focus in [S]
 * @param AT [At] instance to provide a [Lens] to zoom into [S] at [I]
 * @param i index [I] to zoom into [S] and find focus [A]
 * @return [Traversal] with a focus in [A] at given index [I].
 */
public fun  Traversal.at(AT: At, i: I): Traversal = this.compose(AT.at(i))

/**
 * DSL to compose [At] with a [Fold] for a structure [S] to focus in on [A] at given index [I].
 *
 * @receiver [Fold] with a focus in [S]
 * @param AT [At] instance to provide a [Lens] to zoom into [S] at [I]
 * @param i index [I] to zoom into [S] and find focus [A]
 * @return [Fold] with a focus in [A] at given index [I].
 */
public fun  Fold.at(AT: At, i: I): Fold = this.compose(AT.at(i))




© 2015 - 2025 Weber Informatics LLC | Privacy Policy