arrow-optics / arrow.optics / PIso
interface PIso<S, T, A, B> : PIsoOf<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<Option, Option, Int?, String?>
An PIso is also a valid PLens, PPrism
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
| asFold | View a PIso as a Foldopen fun asFold(): Fold<S, A> |
| asGetter | View a PIso as a Getteropen fun asGetter(): Getter<S, A> |
| asLens | View a PIso as a PLensopen fun asLens(): PLens<S, T, A, B> |
| asOptional | View a PIso as a POptionalopen fun asOptional(): POptional<S, T, A, B> |
| asPrism | View a PIso as a PPrismopen fun asPrism(): PPrism<S, T, A, B> |
| asSetter | View a PIso as a PSetteropen fun asSetter(): PSetter<S, T, A, B> |
| asTraversal | View a PIso as a PTraversalopen fun asTraversal(): PTraversal<S, T, A, B> |
| compose | Compose a PIso with a PIsoopen infix fun <C, D> compose(other: PIso<A, B, C, D>): PIso<S, T, C, D>Compose a PIso with a PLens open infix fun <C, D> compose(other: PLens<A, B, C, D>): PLens<S, T, C, D>Compose a PIso with a PPrism open infix fun <C, D> compose(other: PPrism<A, B, C, D>): PPrism<S, T, C, D>Compose a PIso with a Getter open infix fun <C> compose(other: Getter<A, C>): Getter<S, C>Compose a PIso with a PSetter open infix fun <C, D> compose(other: PSetter<A, B, C, D>): PSetter<S, T, C, D>Compose a PIso with a POptional open infix fun <C, D> compose(other: POptional<A, B, C, D>): POptional<S, T, C, D>Compose a PIso with a Fold open infix fun <C> compose(other: Fold<A, C>): Fold<S, C>Compose a PIso with a PTraversal open infix fun <C, D> compose(other: PTraversal<A, B, C, D>): PTraversal<S, T, C, D> |
| exist | Check if the focus satisfies the predicateopen fun exist(s: S, p: (A) -> Boolean): Boolean |
| find | Find if the focus satisfies the predicateopen fun find(s: S, p: (A) -> Boolean): Option<A> |
| first | Create a pair of the PIso and a type Copen fun <C> first(): PIso<Tuple2<S, C>, Tuple2<T, C>, Tuple2<A, C>, Tuple2<B, C>> |
| get | Get the focus of a PIsoabstract fun get(s: S): A |
| left | Create a sum of the PIso and a type Copen fun <C> left(): PIso<Either<S, C>, Either<T, C>, Either<A, C>, Either<B, C>> |
| lift | Modify polymorphically the focus of a PIso with a functionopen fun lift(f: (A) -> B): (S) -> T |
| liftF | Lift a function f with a functor: (A) -> Kind<F, B> to the context of S: (S) -> Kind<F, T>``open fun `open fun |
| mapping | Lift a PIso to a Functor levelopen fun <F> mapping(FF: Functor<F>): PIso<Kind<F, S>, Kind<F, T>, Kind<F, A>, Kind<F, B>> |
| modify | Modify polymorphically the focus of a PIso with a functionopen fun modify(s: S, f: (A) -> B): T |
| modifyF | Modify polymorphically the target of a PIso with a Functor functionopen fun <F> modifyF(FF: Functor<F>, s: S, f: (A) -> Kind<F, B>): Kind<F, T> |
| plus | Plus operator overload to compose lensesopen operator fun <C, D> plus(other: PIso<A, B, C, D>): PIso<S, T, C, D>open operator fun <C, D> plus(other: PLens<A, B, C, D>): PLens<S, T, C, D>open operator fun <C, D> plus(other: PPrism<A, B, C, D>): PPrism<S, T, C, D>open operator fun <C> plus(other: Getter<A, C>): Getter<S, C>open operator fun <C, D> plus(other: PSetter<A, B, C, D>): PSetter<S, T, C, D>open operator fun <C, D> plus(other: POptional<A, B, C, D>): POptional<S, T, C, D>open operator fun <C> plus(other: Fold<A, C>): Fold<S, C>open operator fun <C, D> plus(other: PTraversal<A, B, C, D>): PTraversal<S, T, C, D> |
| reverse | Reverse a PIso: the source becomes the target and the target becomes the sourceopen fun reverse(): PIso<B, A, T, S> |
| reverseGet | Get the modified focus of a PIsoabstract fun reverseGet(b: B): T |
| right | Create a sum of a type C and the PIsoopen fun <C> right(): PIso<Either<C, S>, Either<C, T>, Either<C, A>, Either<C, B>> |
| second | Create a pair of a type C and the PIsoopen fun <C> second(): PIso<Tuple2<C, S>, Tuple2<C, T>, Tuple2<C, A>, Tuple2<C, B>> |
| set | Set polymorphically the focus of a PIso with a valueopen fun set(b: B): T |
| split | Pair two disjoint PIsoopen infix fun <S1, T1, A1, B1> split(other: PIso<S1, T1, A1, B1>): PIso<Tuple2<S, S1>, Tuple2<T, T1>, Tuple2<A, A1>, Tuple2<B, B1>> |
| eitherToPValidated | PIso that defines the equality between Either and Validatedfun <A1, A2, B1, B2> eitherToPValidated(): PIso<Either<A1, B1>, Either<A2, B2>, Validated<A1, B1>, Validated<A2, B2>> |
| eitherToValidated | Iso that defines the equality between Either and Validatedfun <A, B> eitherToValidated(): Iso<Either<A, B>, Validated<A, B>> |
| id | create an PIso between any type and itself. Id is the zero element of optics composition, for any optic o of type O (e.g. PLens, Prism, POptional, …): o compose Iso.id == ofun <S> id(): Iso<S, S> |
| invoke | Invoke operator overload to create a PIso of type S with target A. Can also be used to construct Isooperator fun <S, T, A, B> invoke(get: (S) -> A, reverseGet: (B) -> T): PIso<S, T, A, B> |
| listToOptionNel | Iso that defines equality between a List and Optionfun <A> listToOptionNel(): Iso<List<A>, Option<NonEmptyList<A>>> |
| listToPOptionNel | PIso that defines equality between a List and Optionfun <A, B> listToPOptionNel(): PIso<List<A>, List<B>, Option<NonEmptyList<A>>, Option<NonEmptyList<B>>> |
| mapToSet | Iso that defines the equality between a Unit value Map and a Set with its keysfun <K> mapToSet(): Iso<Map<K, Unit>, Set<K>> |
| optionToEither | Iso that defines the equality between and arrow.core.Option and arrow.core.Eitherfun <A> optionToEither(): Iso<Option<A>, Either<Unit, A>> |
| optionToNullable | PIso that defines the isomorphic relationship between Option and the nullable platform type.fun <A> optionToNullable(): Iso<Option<A>, A?> |
| optionToPEither | Iso that defines the equality between and arrow.core.Option and arrow.core.Eitherfun <A, B> optionToPEither(): PIso<Option<A>, Option<B>, Either<Unit, A>, Either<Unit, B>> |
| optionToPNullable | PIso that defines the equality between Option and the nullable platform type.fun <A, B> optionToPNullable(): PIso<Option<A>, Option<B>, A?, B?> |
| stringToList | Iso that defines equality between String and List of Charfun stringToList(): Iso<String, List<Char>> |
| validatedToEither | Iso that defines equality between Validated and Eitherfun <A, B> validatedToEither(): Iso<Validated<A, B>, Either<A, B>> |
| validatedToPEither | PIso that defines equality between Validated and Eitherfun <A1, A2, B1, B2> validatedToPEither(): PIso<Validated<A1, B1>, Validated<A2, B2>, Either<A1, B1>, Either<A2, B2>> |
| some | DSL to compose a Prism with focus arrow.core.Some with a Iso with a focus of Option<S>val <T, S> Iso<T, Option<S>>.some: Prism<T, S> |
| at | DSL to compose At with an Iso for a structure S to focus in on A at given index I.fun <T, S, I, A> Iso<T, S>.at(AT: At<S, I, A>, i: I): Lens<T, A> |
| every | DSL to compose Each with an Iso for a structure S to see all its foci Afun <T, S, A> Iso<T, S>.~~every~~(EA: Each<S, A>): Traversal<T, A>DSL to compose Traversal with an Iso for a structure S to see all its foci A fun <T, S, A> Iso<T, S>.every(TR: Traversal<S, A>): Traversal<T, A> |
| index | DSL to compose Index with an Iso for a structure S to focus in on A at given index Ifun <T, S, I, A> Iso<T, S>.index(ID: Index<S, I, A>, i: I): Optional<T, A> |
Do you like Arrow?
✖