Refined types#1118
Conversation
|
|
||
| override fun A.refinement(): Boolean = this != 0 | ||
|
|
||
| fun A.nonZero(): Kind<F, A> = refine(this) |
There was a problem hiding this comment.
If I add a method fun nonZero(a: A): Kind<F, A> = a.nonZero() the IDE tells me its signature clashes with this method 🤔
31e2145 to
f4d4ca0
Compare
|
I'm trying to create the same refining mechanism as in https://github.com/fthomas/refined but I don't think I'm doing it right or that if that will work for Kotlin 🤔 I've defined Besides, |
|
|
||
| "Can create GreaterEqual for every number greater or equal than min defined by instance" { | ||
| forAll(GreaterEqualGen(min)) { x: Int -> | ||
| x.greaterEqual(LESS(min)).isValid |
There was a problem hiding this comment.
I would like to have a function with the same signature as less(Ord<Int>, max: Int) instead of passing a Less instance 🤷♂️
|
We wanted to do away with arrow-validation soon. Do you mind keeping this open for a few more days while we decide? |
|
Sure there is no hurry 👌 |
|
Arrow validation has to change from the current use of Either to be a validation library similar in scope to refined. I think this code can be merged in as is as we evolve and deprecate other functions in Arrow Validation which for now can just be ignored for this development. |
8af06ef to
04049cb
Compare
|
I've been trying to implement Modulo and Positive but I'm having some troubles. For For For the moment I think I will stick to the refined types defined in https://github.com/gcanti/newtype-ts which I think I can port them all even though they are very few and silly. Besides, I don't like the Tell me your opinions pls. |
|
Sounds like a good path forward, let me know when ready for review. |
… into cotel-refined-types
|
All the refined types (besides their Which should be our next step? Should I write some documentation on the usage and the definition of custom refined types or should I try to implement more types from the scala library? I would like to stay in this branch if there is no hurry in finishing this 😄 |
|
|
||
| override fun B.refinement(): Boolean = REF().run { !refinement() } | ||
|
|
||
| fun B.not(): Kind<F, B> = refine(this) |
There was a problem hiding this comment.
Should we make these operator?
There was a problem hiding this comment.
Do you mean infix functions? I can overload the not operator which I suppose it would be ! but I cannot overload greater as an operator 🤔
|
|
||
| override fun A.refinement(): Boolean = isGreaterThan(ORD(), this, min()) | ||
|
|
||
| fun A.greater(): Kind<F, A> = refine(this) |
There was a problem hiding this comment.
should we make these operator?
|
|
||
| interface NonZero<F, A : Number> : Refinement<F, A> { | ||
|
|
||
| override fun A.refinement(): Boolean = isNonZero(this) |
There was a problem hiding this comment.
All of these are lawful type classes. We should consider including the laws of each one of them or just for Refinement for now.
That will give users a framework to test their new refined rules that are composed with multiple refinements. No need to be in this PR but would be great to have.
59e727c to
215df8a
Compare
|
I'm trying to run dokka but it tells me that |
|
I still don't know whats going on with dokka/ank. I have tried to compile the arrow-validation project in the arrow-docs project but then ank won't parse a single file. Could anyone look into this? The branch is almost finished except for the docs. |
|
Ank fails because the import is not correct. It should be |
|
Soo I've been trying to fix this for some days now but I have no idea of what to do. The only way I can fix the imports is by including |
|
@Cotel Can we see the output and command you are using? |
|
I'm doing the same the CI is doing ( And its failing with this |
|
@Cotel let's get this merged in once CI passes and continue with more granular features. More action and contributions are coming to |
|
I think this is a good start. We can merge and continue from this point 👍 |
Close #1099
The goal of this PR is to provide a
Refinement<F, A>typeclass for creating refined types and also offering a basic set of them.