Skip to content

Conversation

@fthomas
Copy link
Owner

@fthomas fthomas commented Mar 7, 2021

This works with inline type classes and conditions that can be evaluated
at compile-time like >, !, and ==:

scala> refineMV[Int, Positive1](5)
val res1: eu.timepit.refined.api.Refined[Int, eu.timepit.refined.Positive1] = 5

scala> refineMV[Int, Positive1](-5)
1 |refineMV[Int, Positive1](-5)
  |^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |no

scala> refineMV[String, NonEmpty1]("hello")
val res2: eu.timepit.refined.api.Refined[String, eu.timepit.refined.NonEmpty1] = hello

scala> refineMV[String, NonEmpty1]("")
1 |refineMV[String, NonEmpty1]("")
  |^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |no

This works with inline type classes and conditions that can be evaluated
at compile-time like `>`, `!`, and `==`:
```scala
scala> refineMV[Int, Positive1](5)
val res1: eu.timepit.refined.api.Refined[Int, eu.timepit.refined.Positive1] = 5

scala> refineMV[Int, Positive1](-5)
1 |refineMV[Int, Positive1](-5)
  |^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |no

scala> refineMV[String, NonEmpty1]("hello")
val res2: eu.timepit.refined.api.Refined[String, eu.timepit.refined.NonEmpty1] = hello

scala> refineMV[String, NonEmpty1]("")
1 |refineMV[String, NonEmpty1]("")
  |^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |no
```
@codecov
Copy link

codecov bot commented Mar 7, 2021

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.39%. Comparing base (98aff1d) to head (b3ed76d).
⚠️ Report is 772 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #921   +/-   ##
=======================================
  Coverage   92.39%   92.39%           
=======================================
  Files          63       63           
  Lines         815      815           
  Branches        6        6           
=======================================
  Hits          753      753           
  Misses         62       62           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fthomas fthomas marked this pull request as draft March 8, 2021 06:48
def refineV[P]: RefinePartiallyApplied[Refined, P] = RefType.refinedRefType.refine[P]

trait Predicate[T, P] {
inline def isValid(inline t: T): Boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm giving this a try in armanbilge/lucuma-core#1. Interestingly I had to add transparent to make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants