-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
Type validation using predicates rather than TypeRep's #149
Comments
gets
take predicates instead of TypeRep's
I'd like to keep the possibilities endless. :) I'd like it to remain possible to use Sanctuary without sanctuary-def. It's nice that one could preserve the current behaviour simply by replacing This change would let us replace |
How would this feature work with sanctuary-js/sanctuary-def#28? |
@svozza I would imagine pipe([
gets($.Array.test, ['response', 'body']),
maybeToEither(new Error('Expected response body to be an array'))
]) A good way to think about it, I find, is to think of |
Fair enough, makes sense. I would go the other way though and not mix the concerns of validating types with those of getting a value and have this as a separate function in the pipeline. |
As I remarked in #150, I do think that would be more elegant. But I'm really quite fond of the way these functions force me to do type validation where appropriate. I think it's a good effect to have, and one of my main reasons for using functions that return Monads to begin with. |
I am too. This was the motivation for adding the type arguments in #64. |
Are you interested in working on these changes, @Avaq? |
I am, but I haven't found the time yet. If I do start work on it I'll leave a notice. Until then you're free to pick it up instead, if you have the time. Let me know if you do. :) |
I'll leave this one for you. There are plenty of other issues to keep me occupied for the time being. :) |
ℹ️ I started working on this. |
This commit will close #149 by changing all functions that have built-in type validation to use predicates instead of TypeReps to perform their validations. The functions affected are: * get() * gets() * pluck() * parseJson() The only function untouched is `is()`, for it is used to turn a TypeRep into a predicate.
This commit will close #149 by changing all functions that have built-in type validation to use predicates instead of TypeReps to perform their validations. The functions affected are: * get() * gets() * pluck() * parseJson() The only function untouched is `is()`, for it is used to turn a TypeRep into a predicate.
Oh! Of course! I could've just assigned myself. ;) |
No worries. I appreciated the |
This commit will close #149 by changing all functions that have built-in type validation to use predicates instead of TypeReps to perform their validations. The functions affected are: * get() * gets() * pluck() * parseJson() The only function untouched is `is()`, for it is used to turn a TypeRep into a predicate.
This commit will close #149 by changing all functions that have built-in type validation to use predicates instead of TypeReps to perform their validations. The functions affected are: * get() * gets() * pluck() * parseJson() The only function untouched is `is()`, for it is used to turn a TypeRep into a predicate.
This commit will close #149 by changing all functions that have built-in type validation to use predicates instead of TypeReps to perform their validations. The functions affected are: * get() * gets() * parseJson() The only function untouched is `is()`, for it is used to turn a TypeRep into a predicate.
This commit will close #149 by changing all functions that have built-in type validation to use predicates instead of TypeReps to perform their validations. The functions affected are: * get() * gets() * parseJson() The only function untouched is `is()`, for it is used to turn a TypeRep into a predicate.
This commit will close #149 by changing all functions that have built-in type validation to use predicates instead of TypeReps to perform their validations. The functions affected are: * get() * gets() * parseJson() The only function untouched is `is()`, for it is used to turn a TypeRep into a predicate.
This commit will close #149 by changing all functions that have built-in type validation to use predicates instead of TypeReps to perform their validations. The functions affected are: * get() * gets() * parseJson() The only function untouched is `is()`, for it is used to turn a TypeRep into a predicate.
This commit will close #149 by changing all functions that have built-in type validation to use predicates instead of TypeReps to perform their validations. The functions affected are: * get() * gets() * parseJson() The only function untouched is `is()`, for it is used to turn a TypeRep into a predicate.
Since most type-checking libraries provide convenient ways to get the predicate for a type, this would allow for much greater interoperability with run-time type systems.
With Sanctuary:
With TComb:
With Sanctuary Def:
The possibilities are endless! Another option is to accept Sanctuary Def types, which would make the code a little more concise, but the possibilities slightly less endless.
The text was updated successfully, but these errors were encountered: