-
Notifications
You must be signed in to change notification settings - Fork 157
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
Experiment: refine macro in Scala 3 #921
base: master
Are you sure you want to change the base?
Conversation
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 Report
@@ Coverage Diff @@
## master #921 +/- ##
=======================================
Coverage 92.39% 92.39%
=======================================
Files 63 63
Lines 815 815
Branches 6 6
=======================================
Hits 753 753
Misses 62 62 Continue to review full report at Codecov.
|
@@ -14,6 +14,48 @@ package object refined { | |||
*/ | |||
def refineV[P]: RefinePartiallyApplied[Refined, P] = RefType.refinedRefType.refine[P] | |||
|
|||
trait Predicate[T, P] { | |||
inline def isValid(inline t: T): Boolean |
There was a problem hiding this comment.
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.
This works with inline type classes and conditions that can be evaluated
at compile-time like
>
,!
, and==
: