//arrow-optics/arrow.optics/PIso

common interface PIso<S, T, A, B> : PPrism<S, T, A, B> , PLens<S, T, A, B> , Getter<S, A> , POptional<S, T, A, B> , PSetter<S, T, A, B> , Fold<S, A> , PTraversal<S, T, A, B> , PEvery<S, T, A, B>

An Iso is a loss less invertible optic that defines an isomorphism between a type S and A i.e. a data class and its properties represented by TupleN

A (polymorphic) PIso is useful when setting or modifying a value for a constructed type i.e. PIso

An PIso is also a valid PLens, PPrism

common

S | the source of a PIso |

T | the modified source of a PIso |

A | the focus of a PIso |

B | the modified target of a PIso |

Name | Summary |
---|---|

Companion | common object Companion |

Name | Summary |
---|---|

all | common open fun all(source: S, predicate: (A) -> Boolean): Boolean Check if all targets satisfy the predicate |

any | common open fun any(source: S, predicate: (A) -> Boolean): Boolean Returns `true` if at least one focus matches the given predicate. |

choice | common open infix fun <C> choice(other: Fold<C, A>): Fold<Either<S, C>, A> Join two Fold with the same target common open infix fun <C> choice(other: Getter<C, A>): Getter<Either<S, C>, A> Join two Getter with the same focus common open infix fun <S1, T1> choice(other: PLens<S1, T1, A, B>): PLens<Either<S, S1>, Either<T, T1>, A, B> Join two PLens with the same focus in A common open infix fun <S1, T1> choice(other: POptional<S1, T1, A, B>): POptional<Either<S, S1>, Either<T, T1>, A, B> Join two POptional with the same focus B common open infix fun <U, V> choice(other: PSetter<U, V, A, B>): PSetter<Either<S, U>, Either<T, V>, A, B> Join two PSetter with the same target common open fun <U, V> choice(other: PTraversal<U, V, A, B>): PTraversal<Either<S, U>, Either<T, V>, A, B> |

combineAll | common open fun combineAll(M: Monoid<A>, source: S): A Alias for fold. |

compose | common open infix fun <C> compose(other: Fold<in A, out C>): Fold<S, C> Compose a Fold with a Fold common open infix fun <C> compose(other: Getter<in A, out C>): Getter<S, C> Compose a Getter with a Getter common open infix fun <C, D> compose(other: PEvery<in A, out B, out C, in D>): PEvery<S, T, C, D> Compose a PEvery with a PEvery common open infix fun <C, D> compose(other: PIso<in A, out B, out C, in D>): PIso<S, T, C, D> Compose a PIso with a PIso common open infix fun <C, D> compose(other: PLens<in A, out B, out C, in D>): PLens<S, T, C, D> Compose a PLens with another PLens common open infix fun <C, D> compose(other: POptional<in A, out B, out C, in D>): POptional<S, T, C, D> Compose a POptional with a POptional common open infix fun <C, D> compose(other: PPrism<in A, out B, out C, in D>): PPrism<S, T, C, D> Compose a PPrism with another PPrism common open infix fun <C, D> compose(other: PSetter<in A, out B, out C, in D>): PSetter<S, T, C, D> Compose a PSetter with a PSetter common open infix fun <C, D> compose(other: PTraversal<in A, out B, out C, in D>): PTraversal<S, T, C, D> Compose a PTraversal with a PTraversal |

exists | common open fun exists(source: S, predicate: (A) -> Boolean): Boolean Check whether at least one element satisfies the predicate. |

findOrNull | common open fun findOrNull(source: S, predicate: (A) -> Boolean): A? Find the first element matching the predicate, if one exists. |

first | common open override fun <C> first(): PIso<Pair<S, C>, Pair<T, C>, Pair<A, C>, Pair<B, C» Create a pair of the PIso and a type C |

firstOrNull | common open fun firstOrNull(source: S): A? Get the first target or null |

fold | common open fun fold(M: Monoid<A>, source: S): A Fold using the given Monoid instance. |

foldMap | common open override fun <R> foldMap(M: Monoid<R>, source: S, map: (A) -> R): R Map each target to a type R and use a Monoid to fold the results |

get | common abstract override fun get(source: S): A Get the focus of a PIso |

getAll | common open fun getAll(source: S): List<A> Get all targets of the Fold |

getOrModify | common open override fun getOrModify(source: S): Either<T, A> Get the focus of a POptional or return the original value while allowing the type to change if it does not match |

getOrNull | common open fun getOrNull(source: S): A? Get the focus of a POptional or `null` if the is not there |

isEmpty | common open fun isEmpty(source: S): Boolean Check if there is no target |

isNotEmpty | common open fun isNotEmpty(source: S): Boolean Check if there is at least one target |

lastOrNull | common open fun lastOrNull(source: S): A? Get the last target or null |

left | common open override fun <C> left(): PIso<Either<S, C>, Either<T, C>, Either<A, C>, Either<B, C» Create a sum of the PIso and a type C |

lift | common open fun lift(map: (A) -> B): (S) -> T Lift a function map: `(A) -> B to the context of ` S`: ` (S) -> T` |

liftNullable | common open fun liftNullable(f: (A) -> B): (S) -> T? Lift a function f: `(A) -> B to the context of ` S`: ` (S) -> T?` |

modify | common open override fun modify(source: S, map: (A) -> B): T Modify polymorphically the focus of a PIso with a function |

modifyNullable | common open fun modifyNullable(source: S, map: (A) -> B): T? Modify the focus of a POptional with a function map |

plus | common open operator fun <C> plus(other: Fold<in A, out C>): Fold<S, C> open operator fun <C> plus(other: Getter<in A, out C>): Getter<S, C> open operator fun <C, D> plus(other: PEvery<in A, out B, out C, in D>): PEvery<S, T, C, D> open operator fun <C, D> plus(other: PIso<in A, out B, out C, in D>): PIso<S, T, C, D> open operator fun <C, D> plus(other: PLens<in A, out B, out C, in D>): PLens<S, T, C, D> open operator fun <C, D> plus(other: POptional<in A, out B, out C, in D>): POptional<S, T, C, D> open operator fun <C, D> plus(other: PPrism<in A, out B, out C, in D>): PPrism<S, T, C, D> open operator fun <C, D> plus(other: PSetter<in A, out B, out C, in D>): PSetter<S, T, C, D> open operator fun <C, D> plus(other: PTraversal<in A, out B, out C, in D>): PTraversal<S, T, C, D> |

reverse | common open fun reverse(): PIso<B, A, T, S> Reverse a PIso: the source becomes the target and the target becomes the source |

reverseGet | common abstract override fun reverseGet(focus: B): T Get the modified focus of a PIso |

right | common open override fun <C> right(): PIso<Either<C, S>, Either<C, T>, Either<C, A>, Either<C, B» Create a sum of a type C and the PIso |

second | common open override fun <C> second(): PIso<Pair<C, S>, Pair<C, T>, Pair<C, A>, Pair<C, B» Create a pair of a type C and the PIso |

set | common open fun set(b: B): T Set polymorphically the focus of a PIso with a value common open override fun set(source: S, focus: B): T Set the focus of a PPrism with a value |

setNullable | common open fun setNullable(source: S, b: B): T? Set the focus of a POptional with a value. |

size | common open fun size(source: S): Int Calculate the number of targets |

split | common open infix fun <C, D> split(other: Getter<C, D>): Getter<Pair<S, C>, Pair<A, D» Pair two disjoint Getter common open infix fun <S1, T1, A1, B1> split(other: PIso<S1, T1, A1, B1>): PIso<Pair<S, S1>, Pair<T, T1>, Pair<A, A1>, Pair<B, B1» Pair two disjoint PIso common open infix fun <S1, T1, A1, B1> split(other: PLens<S1, T1, A1, B1>): PLens<Pair<S, S1>, Pair<T, T1>, Pair<A, A1>, Pair<B, B1» Pair two disjoint PLens |

zip | common open infix fun <C> zip(other: Getter<S, C>): Getter<S, Pair<A, C» Zip two Getter optics with the same source S |

Name | Summary |
---|---|

every | common open val <U, V> PLens<U, V, S, T>.every: PTraversal<U, V, A, B> DSL to compose Traversal with a Lens for a structure S to see all its foci A |

every | common open val <U, V> PIso<U, V, S, T>.every: PTraversal<U, V, A, B> DSL to compose Traversal with a Iso for a structure S to see all its foci A |

every | common open val <U, V> PPrism<U, V, S, T>.every: PTraversal<U, V, A, B> DSL to compose Traversal with a Prism for a structure S to see all its foci A |

every | common open val <U, V> POptional<U, V, S, T>.every: PTraversal<U, V, A, B> DSL to compose Traversal with a Optional for a structure S to see all its foci A |

every | common open val <U, V> PSetter<U, V, S, T>.every: PSetter<U, V, A, B> DSL to compose Traversal with a Setter for a structure S to see all its foci A |

every | common open val <U, V> PTraversal<U, V, S, T>.every: PTraversal<U, V, A, B> DSL to compose Traversal with a Traversal for a structure S to see all its foci A |

every | common open val <U, V> PEvery<U, V, S, T>.every: PTraversal<U, V, A, B> DSL to compose Traversal with a PEvery for a structure S to see all its foci A |

Do you like Arrow?

✖