Skip to content
New issue

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

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

Already on GitHub? # to your account

Add bindFirst and curried methods for Poly #708

Merged
merged 1 commit into from
Mar 19, 2020
Merged

Conversation

Atry
Copy link
Contributor

@Atry Atry commented Apr 21, 2017

No description provided.

@codecov-io
Copy link

codecov-io commented Apr 21, 2017

Codecov Report

Merging #708 into master will decrease coverage by 21.98%.
The diff coverage is 52.63%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #708       +/-   ##
===========================================
- Coverage   83.58%   61.59%   -21.99%     
===========================================
  Files          66       94       +28     
  Lines        2608     3552      +944     
  Branches       90      114       +24     
===========================================
+ Hits         2180     2188        +8     
- Misses        428     1364      +936
Impacted Files Coverage Δ
core/src/main/scala/shapeless/poly.scala 0% <0%> (-77.5%) ⬇️
core/src/test/scala/shapeless/poly.scala 81.25% <90.9%> (ø)
core/src/main/scala/shapeless/conversions.scala 0% <0%> (-100%) ⬇️
core/src/main/scala/shapeless/cached.scala 0% <0%> (-100%) ⬇️
core/src/main/scala/shapeless/unwrapped.scala 0% <0%> (-100%) ⬇️
core/src/main/scala_2.10/shapeless/lazyref.scala 0% <0%> (-100%) ⬇️
core/src/main/scala/shapeless/alacarte.scala 0% <0%> (-100%) ⬇️
...re/src/main/scala/shapeless/hlistconstraints.scala 0% <0%> (-100%) ⬇️
core/src/main/scala/shapeless/default.scala 0% <0%> (-100%) ⬇️
core/src/main/scala/shapeless/lowpriority.scala 0% <0%> (-100%) ⬇️
... and 48 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 745db7e...a9347e6. Read the comment docs.

@Atry
Copy link
Contributor Author

Atry commented Apr 22, 2017

@milessabin Why did the code coverage change?

@milessabin
Copy link
Owner

This looks very useful ... thanks!

A few things before I merge. Do these work as expected as arguments to a Mapper? If not, then I suspect they would if the instances were moved to the corresponding CaseN companions. Either way, would you mind adding some tests of this case.

Also some stylistic things. shapeless intentionally doesn't use access modifiers (other than private[this] where it's interaction with variance can be useful). Also please could you adjust your use of whitespace to match the rest of the project (ie. two space indents with aggressive line breaking).

@Atry
Copy link
Contributor Author

Atry commented May 2, 2017

Yes, Mapper is my use case, too.

However, there is a limitation:

The newly created Poly from bindFirst or curried must be visible at the call site, which is impossible for some complicated case.

@milessabin
Copy link
Owner

Still waiting on tests and the stylistic changes requested.

@joroKr21
Copy link
Collaborator

joroKr21 commented Mar 19, 2020

Rebased to remove whitespace from diff and add some tests with map and foldLeft.
@milessabin regarding stylistic changes I think if we want a consistent style we should setup scalafmt.

@Atry
Copy link
Contributor Author

Atry commented Mar 19, 2020

Thank you for picking up this PR @joroKr21

}
}

final case class Curried[F, ParameterAccumulator <: HList](parameters: ParameterAccumulator) extends Poly1
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Atry do you remember what the ParameterAccumulator type parameter is for?
It seems unused to me = always HNil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

    object p extends Poly3 {
      implicit def x = at[Int, Double, String] { (i, d, s) =>
        s"$i, $d, $s"
      }
    }

    val c = Poly.curried(p)
    val c1 = c(1)
    val c2 = c1(42.5)

Try printing c2.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah ok that makes sense 👍

@joroKr21 joroKr21 merged commit 098d8b0 into milessabin:master Mar 19, 2020
@Atry Atry deleted the patch-8 branch March 23, 2020 21:20
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants