Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parameter order in extension functions in arrow-instances-core #793

Merged
merged 16 commits into from
Apr 21, 2018

Conversation

pakoito
Copy link
Member

@pakoito pakoito commented Apr 14, 2018

No description provided.

@pakoito pakoito requested review from raulraja and a team April 14, 2018 12:43
Copy link
Member

@raulraja raulraja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not for this PR but we should add sequence also because people are using traverse(GA, ::identity) when they just want sequence(GA)

@pakoito
Copy link
Member Author

pakoito commented Apr 14, 2018

@raulraja
Copy link
Member

raulraja commented Apr 14, 2018

I mean as extensions to the kinded versions of the actual data types. ListK for example has no sequence. All data types that can implement traverse and sequence should expose it as an operation over their concrete self without relying on the Traverse instance to derive it from traverse.
In many cases people want to sequence just simple concrete values like ListK<DeferredK<A>> -> DeferredK<ListK<A>> and they are using traverse because is the only combinator ListK exposes directly.

@@ -101,8 +102,8 @@ interface IdFoldableInstance : Foldable<ForId> {
fix().foldRight(lb, f)
}

fun <A, G, B> Id<A>.traverse(f: (A) -> Kind<G, B>, GA: Applicative<G>): Kind<G, Id<B>> = GA.run {
f(fix().value).map({ Id(it) })
fun <A, G, B> Id<A>.traverse(GA: Applicative<G>, f: (A) -> Kind<G, B>): Kind<G, Id<B>> = GA.run {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IdOf<A> ?

@@ -99,7 +100,7 @@ interface TryFoldableInstance : Foldable<ForTry> {
fix().foldRight(lb, f)
}

fun <A, B, G> Try<A>.traverse(f: (A) -> Kind<G, B>, GA: Applicative<G>): Kind<G, Try<B>> = GA.run {
fun <A, B, G> Try<A>.traverse(GA: Applicative<G>, f: (A) -> Kind<G, B>): Kind<G, Try<B>> = GA.run {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TryOf<A>?

@codecov
Copy link

codecov bot commented Apr 18, 2018

Codecov Report

Merging #793 into master will decrease coverage by 0.08%.
The diff coverage is 61.97%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master    #793      +/-   ##
===========================================
- Coverage     43.58%   43.5%   -0.09%     
  Complexity      584     584              
===========================================
  Files           284     284              
  Lines          7245    7259      +14     
  Branches        809     804       -5     
===========================================
  Hits           3158    3158              
- Misses         3802    3819      +17     
+ Partials        285     282       -3
Impacted Files Coverage Δ Complexity Δ
...-data/src/main/kotlin/arrow/instances/coproduct.kt 77.77% <ø> (ø) 0 <0> (ø) ⬇️
...arrow-data/src/main/kotlin/arrow/data/SequenceK.kt 78.37% <0%> (-2.18%) 8 <0> (ø)
...nces-core/src/main/kotlin/arrow/instances/tuple.kt 0% <0%> (ø) 0 <0> (ø) ⬇️
.../core/arrow-data/src/main/kotlin/arrow/data/Ior.kt 41.48% <0%> (-0.45%) 21 <0> (ø)
...s-rx2/src/main/kotlin/arrow/effects/ObservableK.kt 68.08% <0%> (-1.49%) 8 <0> (ø)
...ow-data/src/main/kotlin/arrow/data/NonEmptyList.kt 69.35% <0%> (-1.14%) 21 <0> (ø)
...arrow-data/src/main/kotlin/arrow/data/Coproduct.kt 60% <0%> (-3.16%) 7 <0> (ø)
...core/arrow-data/src/main/kotlin/arrow/data/MapK.kt 40.54% <0%> (-1.13%) 5 <0> (ø)
...cts-rx2/src/main/kotlin/arrow/effects/FlowableK.kt 54.05% <0%> (-0.75%) 8 <0> (ø)
...ore/arrow-data/src/main/kotlin/arrow/data/ListK.kt 93.93% <0%> (-2.94%) 12 <0> (ø)
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 54f1d91...fe661c0. Read the comment docs.

@pakoito pakoito merged commit a8ea41a into master Apr 21, 2018
@pakoito pakoito deleted the paco-fixtraverseextfunsincore branch April 21, 2018 19:16
RawToast pushed a commit to RawToast/kategory that referenced this pull request Jul 18, 2018
…d add sequence to all traversable datatypes (arrow-kt#793)

* Fix parameter order in extension functions in arrow-instances-core

* Fix stackoverflow

* Add sequence to some traversable datatypes

* Fix stackoverflow

* Add sequence to remaining datatypes with traverse

* Add sequence to remaining datatypes with traverse

* Fix ank
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants