-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,6 +211,7 @@ abstract interface <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?, #D: kotli | |
abstract fun modify(#A, kotlin/Function1<#C, #D>): #B // arrow.optics/PTraversal.modify|modify(1:0;kotlin.Function1<1:2,1:3>){}[0] | ||
open fun <#A1: kotlin/Any?, #B1: kotlin/Any?> choice(arrow.optics/PTraversal<#A1, #B1, #C, #D>): arrow.optics/PTraversal<arrow.core/Either<#A, #A1>, arrow.core/Either<#B, #B1>, #C, #D> // arrow.optics/PTraversal.choice|choice(arrow.optics.PTraversal<0:0,0:1,1:2,1:3>){0§<kotlin.Any?>;1§<kotlin.Any?>}[0] | ||
open fun <#A1: kotlin/Any?, #B1: kotlin/Any?> compose(arrow.optics/PTraversal<in #C, out #D, out #A1, in #B1>): arrow.optics/PTraversal<#A, #B, #A1, #B1> // arrow.optics/PTraversal.compose|compose(arrow.optics.PTraversal<in|1:2,out|1:3,out|0:0,in|0:1>){0§<kotlin.Any?>;1§<kotlin.Any?>}[0] | ||
open fun <#A1: kotlin/Any?, #B1: kotlin/Any?> composeLazy(kotlin/Function0<arrow.optics/PTraversal<in #C, out #D, out #A1, in #B1>>): arrow.optics/PTraversal<#A, #B, #A1, #B1> // arrow.optics/PTraversal.composeLazy|composeLazy(kotlin.Function0<arrow.optics.PTraversal<in|1:2,out|1:3,out|0:0,in|0:1>>){0§<kotlin.Any?>;1§<kotlin.Any?>}[0] | ||
open fun <#A1: kotlin/Any?, #B1: kotlin/Any?> plus(arrow.optics/PTraversal<in #C, out #D, out #A1, in #B1>): arrow.optics/PTraversal<#A, #B, #A1, #B1> // arrow.optics/PTraversal.plus|plus(arrow.optics.PTraversal<in|1:2,out|1:3,out|0:0,in|0:1>){0§<kotlin.Any?>;1§<kotlin.Any?>}[0] | ||
open fun all(#A, kotlin/Function1<#C, kotlin/Boolean>): kotlin/Boolean // arrow.optics/PTraversal.all|all(1:0;kotlin.Function1<1:2,kotlin.Boolean>){}[0] | ||
open fun any(#A, kotlin/Function1<#C, kotlin/Boolean>): kotlin/Boolean // arrow.optics/PTraversal.any|any(1:0;kotlin.Function1<1:2,kotlin.Boolean>){}[0] | ||
|
@@ -359,6 +360,8 @@ final fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.optics/POpt | |
final fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.optics/POptional<#A, #A, kotlin.collections/Map<#B, #C>, kotlin.collections/Map<#B, #C>>).arrow.optics.dsl/index(#B): arrow.optics/POptional<#A, #A, #C, #C> // arrow.optics.dsl/index|[email protected]<0:0,0:0,kotlin.collections.Map<0:1,0:2>,kotlin.collections.Map<0:1,0:2>>(0:1){0§<kotlin.Any?>;1§<kotlin.Any?>;2§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.optics/PTraversal.Companion).arrow.optics/fromLenses(arrow.optics/PLens<#A, #A, #B, #C>, kotlin/Array<out arrow.optics/PLens<#A, #A, #B, #C>>...): arrow.optics/PTraversal<#A, #A, #B, #C> // arrow.optics/fromLenses|[email protected](arrow.optics.PLens<0:0,0:0,0:1,0:2>;kotlin.Array<out|arrow.optics.PLens<0:0,0:0,0:1,0:2>>...){0§<kotlin.Any?>;1§<kotlin.Any?>;2§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.optics/PTraversal<#A, #A, #B, #B>).arrow.optics.dsl/every(arrow.optics/PTraversal<#B, #B, #C, #C>): arrow.optics/PTraversal<#A, #A, #C, #C> // arrow.optics.dsl/every|[email protected]<0:0,0:0,0:1,0:1>(arrow.optics.PTraversal<0:1,0:1,0:2,0:2>){0§<kotlin.Any?>;1§<kotlin.Any?>;2§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.optics/PTraversal<#A, #A, #B, #C>).arrow.optics.regex/and(arrow.optics/PTraversal<#A, #A, #B, #C>): arrow.optics/PTraversal<#A, #A, #B, #C> // arrow.optics.regex/and|[email protected]<0:0,0:0,0:1,0:2>(arrow.optics.PTraversal<0:0,0:0,0:1,0:2>){0§<kotlin.Any?>;1§<kotlin.Any?>;2§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.optics/PTraversal<#A, #A, #B, #C>).arrow.optics.regex/times(arrow.optics/PTraversal<#A, #A, #B, #C>): arrow.optics/PTraversal<#A, #A, #B, #C> // arrow.optics.regex/times|[email protected]<0:0,0:0,0:1,0:2>(arrow.optics.PTraversal<0:0,0:0,0:1,0:2>){0§<kotlin.Any?>;1§<kotlin.Any?>;2§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.optics/PTraversal<#A, #A, kotlin.collections/Map<#B, #C>, kotlin.collections/Map<#B, #C>>).arrow.optics.dsl/at(#B): arrow.optics/PTraversal<#A, #A, arrow.core/Option<#C>, arrow.core/Option<#C>> // arrow.optics.dsl/at|[email protected]<0:0,0:0,kotlin.collections.Map<0:1,0:2>,kotlin.collections.Map<0:1,0:2>>(0:1){0§<kotlin.Any?>;1§<kotlin.Any?>;2§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.optics/PTraversal<#A, #A, kotlin.collections/Map<#B, #C>, kotlin.collections/Map<#B, #C>>).arrow.optics.dsl/filterIndex(kotlin/Function1<#B, kotlin/Boolean>): arrow.optics/PTraversal<#A, #A, #C, #C> // arrow.optics.dsl/filterIndex|[email protected]<0:0,0:0,kotlin.collections.Map<0:1,0:2>,kotlin.collections.Map<0:1,0:2>>(kotlin.Function1<0:1,kotlin.Boolean>){0§<kotlin.Any?>;1§<kotlin.Any?>;2§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?> (arrow.optics/PTraversal<#A, #A, kotlin.collections/Map<#B, #C>, kotlin.collections/Map<#B, #C>>).arrow.optics.dsl/index(#B): arrow.optics/PTraversal<#A, #A, #C, #C> // arrow.optics.dsl/index|[email protected]<0:0,0:0,kotlin.collections.Map<0:1,0:2>,kotlin.collections.Map<0:1,0:2>>(0:1){0§<kotlin.Any?>;1§<kotlin.Any?>;2§<kotlin.Any?>}[0] | ||
|
@@ -376,6 +379,8 @@ final fun <#A: kotlin/Any?, #B: kotlin/Any?> (arrow.optics/POptional<#A, #A, kot | |
final fun <#A: kotlin/Any?, #B: kotlin/Any?> (arrow.optics/POptional<#A, #A, kotlin.collections/Set<#B>, kotlin.collections/Set<#B>>).arrow.optics.dsl/at(#B): arrow.optics/POptional<#A, #A, kotlin/Boolean, kotlin/Boolean> // arrow.optics.dsl/at|[email protected]<0:0,0:0,kotlin.collections.Set<0:1>,kotlin.collections.Set<0:1>>(0:1){0§<kotlin.Any?>;1§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?, #B: kotlin/Any?> (arrow.optics/POptional<#A, #A, kotlin.sequences/Sequence<#B>, kotlin.sequences/Sequence<#B>>).arrow.optics.dsl/index(kotlin/Int): arrow.optics/POptional<#A, #A, #B, #B> // arrow.optics.dsl/index|[email protected]<0:0,0:0,kotlin.sequences.Sequence<0:1>,kotlin.sequences.Sequence<0:1>>(kotlin.Int){0§<kotlin.Any?>;1§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?, #B: kotlin/Any?> (arrow.optics/PTraversal<#A, #A, #B, #B>).arrow.optics.dsl/filter(kotlin/Function1<#B, kotlin/Boolean>): arrow.optics/PTraversal<#A, #A, #B, #B> // arrow.optics.dsl/filter|[email protected]<0:0,0:0,0:1,0:1>(kotlin.Function1<0:1,kotlin.Boolean>){0§<kotlin.Any?>;1§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?, #B: kotlin/Any?> (arrow.optics/PTraversal<#A, #A, #B, #B>).arrow.optics.regex.dsl/onceOrMore(arrow.optics/PTraversal<#B, #B, #B, #B>): arrow.optics/PTraversal<#A, #A, #B, #B> // arrow.optics.regex.dsl/onceOrMore|[email protected]<0:0,0:0,0:1,0:1>(arrow.optics.PTraversal<0:1,0:1,0:1,0:1>){0§<kotlin.Any?>;1§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?, #B: kotlin/Any?> (arrow.optics/PTraversal<#A, #A, #B, #B>).arrow.optics.regex.dsl/zeroOrMore(arrow.optics/PTraversal<#B, #B, #B, #B>): arrow.optics/PTraversal<#A, #A, #B, #B> // arrow.optics.regex.dsl/zeroOrMore|[email protected]<0:0,0:0,0:1,0:1>(arrow.optics.PTraversal<0:1,0:1,0:1,0:1>){0§<kotlin.Any?>;1§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?, #B: kotlin/Any?> (arrow.optics/PTraversal<#A, #A, arrow.core/NonEmptyList<#B>, arrow.core/NonEmptyList<#B>>).arrow.optics.dsl/filterIndex(kotlin/Function1<kotlin/Int, kotlin/Boolean>): arrow.optics/PTraversal<#A, #A, #B, #B> // arrow.optics.dsl/filterIndex|[email protected]<0:0,0:0,arrow.core.NonEmptyList<0:1>,arrow.core.NonEmptyList<0:1>>(kotlin.Function1<kotlin.Int,kotlin.Boolean>){0§<kotlin.Any?>;1§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?, #B: kotlin/Any?> (arrow.optics/PTraversal<#A, #A, arrow.core/NonEmptyList<#B>, arrow.core/NonEmptyList<#B>>).arrow.optics.dsl/index(kotlin/Int): arrow.optics/PTraversal<#A, #A, #B, #B> // arrow.optics.dsl/index|[email protected]<0:0,0:0,arrow.core.NonEmptyList<0:1>,arrow.core.NonEmptyList<0:1>>(kotlin.Int){0§<kotlin.Any?>;1§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?, #B: kotlin/Any?> (arrow.optics/PTraversal<#A, #A, kotlin.collections/List<#B>, kotlin.collections/List<#B>>).arrow.optics.dsl/filterIndex(kotlin/Function1<kotlin/Int, kotlin/Boolean>): arrow.optics/PTraversal<#A, #A, #B, #B> // arrow.optics.dsl/filterIndex|[email protected]<0:0,0:0,kotlin.collections.List<0:1>,kotlin.collections.List<0:1>>(kotlin.Function1<kotlin.Int,kotlin.Boolean>){0§<kotlin.Any?>;1§<kotlin.Any?>}[0] | ||
|
@@ -398,5 +403,7 @@ final fun <#A: kotlin/Any?> (kotlin.collections/List<#A>).arrow.optics/uncons(): | |
final fun <#A: kotlin/Any?> (kotlin.collections/List<#A>).arrow.optics/unsnoc(): kotlin/Pair<kotlin.collections/List<#A>, #A>? // arrow.optics/unsnoc|[email protected]<0:0>(){0§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?> arrow.optics.match/equalsTo(#A): arrow.optics/POptional<#A, #A, #A, #A> // arrow.optics.match/equalsTo|equalsTo(0:0){0§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?> arrow.optics.match/predicate(kotlin/Function1<#A, kotlin/Boolean>): arrow.optics/POptional<#A, #A, #A, #A> // arrow.optics.match/predicate|predicate(kotlin.Function1<0:0,kotlin.Boolean>){0§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?> arrow.optics.regex/onceOrMore(arrow.optics/PTraversal<#A, #A, #A, #A>): arrow.optics/PTraversal<#A, #A, #A, #A> // arrow.optics.regex/onceOrMore|onceOrMore(arrow.optics.PTraversal<0:0,0:0,0:0,0:0>){0§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?> arrow.optics.regex/zeroOrMore(arrow.optics/PTraversal<#A, #A, #A, #A>): arrow.optics/PTraversal<#A, #A, #A, #A> // arrow.optics.regex/zeroOrMore|zeroOrMore(arrow.optics.PTraversal<0:0,0:0,0:0,0:0>){0§<kotlin.Any?>}[0] | ||
final inline fun <#A: kotlin/Any, #B: reified #A> arrow.optics.match/instanceOf(): arrow.optics/POptional<#A, #A, #B, #B> // arrow.optics.match/instanceOf|instanceOf(){0§<kotlin.Any>;1§<0:0>}[0] | ||
final inline fun <#A: kotlin/Any?, #B: kotlin/Any, #C: reified #B> (arrow.optics/POptional<#A, #A, #B, #B>).arrow.optics.match/ifInstanceOf(): arrow.optics/POptional<#A, #A, #C, #C> // arrow.optics.match/ifInstanceOf|[email protected]<0:0,0:0,0:1,0:1>(){0§<kotlin.Any?>;1§<kotlin.Any>;2§<0:1>}[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/regex/Regex.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package arrow.optics.regex | ||
|
||
import arrow.optics.Iso | ||
import arrow.optics.Traversal | ||
import arrow.optics.PTraversal | ||
|
||
/** | ||
* [Traversal] that aggregates the elements of two other traversals. | ||
* | ||
* For example, this may aggregate the values coming from several fields of the same type. | ||
*/ | ||
public infix fun <T, A, B> PTraversal<T, T, A, B>.and(other: PTraversal<T, T, A, B>): PTraversal<T, T, A, B> = | ||
object : PTraversal<T, T, A, B> { | ||
override fun <R> foldMap(initial: R, combine: (R, R) -> R, source: T, map: (focus: A) -> R): R { | ||
val meFolded = this@and.foldMap(initial, combine, source, map) | ||
val otherFolded = other.foldMap(initial, combine, source, map) | ||
return combine(meFolded, otherFolded) | ||
} | ||
|
||
override fun modify(source: T, map: (focus: A) -> B): T = | ||
other.modify(this@and.modify(source, map), map) | ||
} | ||
|
||
/** | ||
* [Traversal] that aggregates the elements of two other traversals. | ||
* | ||
* For example, this may aggregate the values coming from several fields of the same type. | ||
*/ | ||
public operator fun <T, A, B> PTraversal<T, T, A, B>.times(other: PTraversal<T, T, A, B>): PTraversal<T, T, A, B> = | ||
this and other | ||
|
||
/** | ||
* Aggregates the elements by "going into" the desired traversal repeatedly. | ||
* This traversal is especially useful to inspect values which contain fields of | ||
* the same type within them. | ||
* | ||
* **Important**: [onceOrMore] may operate over the same value more than once, | ||
* if there is more than one path arriving to it. | ||
*/ | ||
public fun <A> onceOrMore(traversal: Traversal<A, A>): Traversal<A, A> = | ||
traversal composeLazy { zeroOrMore(traversal) } | ||
|
||
/** | ||
* Aggregates the elements by "going into" the desired traversal repeatedly, | ||
* including the starting value itself. | ||
* This traversal is especially useful to inspect values which contain fields of | ||
* the same type within them. | ||
* | ||
* **Important**: [zeroOrMore] may operate over the same value more than once, | ||
* if there is more than one path arriving to it. | ||
*/ | ||
public fun <A> zeroOrMore(traversal: Traversal<A, A>): Traversal<A, A> = | ||
Iso.id<A>() and onceOrMore(traversal) |
11 changes: 11 additions & 0 deletions
11
arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/regex/dsl/Regex.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package arrow.optics.regex.dsl | ||
|
||
import arrow.optics.regex.onceOrMore as regexOnceOrMore | ||
import arrow.optics.regex.zeroOrMore as regexZeroOrMore | ||
import arrow.optics.Traversal | ||
|
||
public fun <S, A> Traversal<S, A>.onceOrMore(traversal: Traversal<A, A>): Traversal<S, A> = | ||
this compose regexOnceOrMore(traversal) | ||
|
||
public fun <S, A> Traversal<S, A>.zeroOrMore(traversal: Traversal<A, A>): Traversal<S, A> = | ||
this compose regexZeroOrMore(traversal) |
Oops, something went wrong.