Skip to content

Commit

Permalink
Fix traversal invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
serras committed Jan 21, 2025
1 parent 095c598 commit 9fcc9f8
Showing 1 changed file with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public interface PTraversal<S, T, A, B> {
initial: R,
combine: (R, R) -> R,
source: Either<S, U>,
map: (focus: A) -> R
map: (focus: A) -> R,
): R = source.fold(
{ a -> this@PTraversal.foldMap(initial, combine, a, map) },
{ u -> other.foldMap(initial, combine, u, map) }
Expand Down Expand Up @@ -201,7 +201,7 @@ public interface PTraversal<S, T, A, B> {
public operator fun <S, T, A, B> invoke(
get1: (S) -> A,
get2: (S) -> A,
set: (B, B, S) -> T
set: (B, B, S) -> T,
): PTraversal<S, T, A, B> =
object : PTraversal<S, T, A, B> {
override fun <R> foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R =
Expand All @@ -215,7 +215,7 @@ public interface PTraversal<S, T, A, B> {
get1: (S) -> A,
get2: (S) -> A,
get3: (S) -> A,
set: (B, B, B, S) -> T
set: (B, B, B, S) -> T,
): PTraversal<S, T, A, B> =
object : PTraversal<S, T, A, B> {
override fun <R> foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R =
Expand All @@ -230,7 +230,7 @@ public interface PTraversal<S, T, A, B> {
get2: (S) -> A,
get3: (S) -> A,
get4: (S) -> A,
set: (B, B, B, B, S) -> T
set: (B, B, B, B, S) -> T,
): PTraversal<S, T, A, B> =
object : PTraversal<S, T, A, B> {
override fun <R> foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R =
Expand All @@ -246,11 +246,11 @@ public interface PTraversal<S, T, A, B> {
get3: (S) -> A,
get4: (S) -> A,
get5: (S) -> A,
set: (B, B, B, B, B, S) -> T
set: (B, B, B, B, B, S) -> T,
): PTraversal<S, T, A, B> =
object : PTraversal<S, T, A, B> {
override fun <R> foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R =
combine(combine(combine(map(get1(source)), map(get2(source))), map(get3(source))), map(get5(source)))
combine(combine(combine(combine(map(get1(source)), map(get2(source))), map(get3(source))), map(get4(source))), map(get5(source)))

override fun modify(source: S, map: (focus: A) -> B): T =
set(map(get1(source)), map(get2(source)), map(get3(source)), map(get4(source)), map(get5(source)), source)
Expand All @@ -263,11 +263,11 @@ public interface PTraversal<S, T, A, B> {
get4: (S) -> A,
get5: (S) -> A,
get6: (S) -> A,
set: (B, B, B, B, B, B, S) -> T
set: (B, B, B, B, B, B, S) -> T,
): PTraversal<S, T, A, B> =
object : PTraversal<S, T, A, B> {
override fun <R> foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R =
combine(combine(combine(combine(map(get1(source)), map(get2(source))), map(get3(source))), map(get5(source))), map(get6(source)))
combine(combine(combine(combine(combine(map(get1(source)), map(get2(source))), map(get3(source))), map(get4(source))), map(get5(source))), map(get6(source)))

override fun modify(source: S, map: (focus: A) -> B): T =
set(map(get1(source)), map(get2(source)), map(get3(source)), map(get4(source)), map(get5(source)), map(get6(source)), source)
Expand All @@ -281,13 +281,15 @@ public interface PTraversal<S, T, A, B> {
get5: (S) -> A,
get6: (S) -> A,
get7: (S) -> A,
set: (B, B, B, B, B, B, B, S) -> T
set: (B, B, B, B, B, B, B, S) -> T,
): PTraversal<S, T, A, B> =
object : PTraversal<S, T, A, B> {
override fun <R> foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R =
combine(
combine(combine(combine(combine(map(get1(source)), map(get2(source))), map(get3(source))), map(get5(source))), map(get6(source))),
map(get7(source))
combine(
combine(combine(combine(combine(map(get1(source)), map(get2(source))), map(get3(source))), map(get4(source))), map(get5(source))),
map(get6(source))
), map(get7(source))
)

override fun modify(source: S, map: (focus: A) -> B): T =
Expand All @@ -303,15 +305,17 @@ public interface PTraversal<S, T, A, B> {
get6: (S) -> A,
get7: (S) -> A,
get8: (S) -> A,
set: (B, B, B, B, B, B, B, B, S) -> T
set: (B, B, B, B, B, B, B, B, S) -> T,
): PTraversal<S, T, A, B> =
object : PTraversal<S, T, A, B> {
override fun <R> foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R =
combine(
combine(
combine(
combine(combine(combine(map(get1(source)), map(get2(source))), map(get3(source))), map(get5(source))),
map(get6(source))
combine(
combine(combine(combine(map(get1(source)), map(get2(source))), map(get3(source))), map(get4(source))),
map(get5(source))
), map(get6(source))
), map(get7(source))
), map(get8(source))
)
Expand All @@ -330,16 +334,18 @@ public interface PTraversal<S, T, A, B> {
get7: (S) -> A,
get8: (S) -> A,
get9: (S) -> A,
set: (B, B, B, B, B, B, B, B, B, S) -> T
set: (B, B, B, B, B, B, B, B, B, S) -> T,
): PTraversal<S, T, A, B> =
object : PTraversal<S, T, A, B> {
override fun <R> foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R =
combine(
combine(
combine(
combine(
combine(combine(combine(map(get1(source)), map(get2(source))), map(get3(source))), map(get5(source))),
map(get6(source))
combine(
combine(combine(combine(map(get1(source)), map(get2(source))), map(get3(source))), map(get4(source))),
map(get5(source))
), map(get6(source))
), map(get7(source))
), map(get8(source))
), map(get9(source))
Expand Down Expand Up @@ -371,7 +377,7 @@ public interface PTraversal<S, T, A, B> {
get8: (S) -> A,
get9: (S) -> A,
get10: (S) -> A,
set: (B, B, B, B, B, B, B, B, B, B, S) -> T
set: (B, B, B, B, B, B, B, B, B, B, S) -> T,
): PTraversal<S, T, A, B> =
object : PTraversal<S, T, A, B> {
override fun <R> foldMap(initial: R, combine: (R, R) -> R, source: S, map: (focus: A) -> R): R =
Expand All @@ -381,8 +387,10 @@ public interface PTraversal<S, T, A, B> {
combine(
combine(
combine(
combine(combine(map(get1(source)), map(get2(source))), map(get3(source))),
map(get5(source))
combine(
combine(combine(map(get1(source)), map(get2(source))), map(get3(source))),
map(get4(source))
), map(get5(source))
), map(get6(source))
), map(get7(source))
), map(get8(source))
Expand Down

0 comments on commit 9fcc9f8

Please sign in to comment.