-
Notifications
You must be signed in to change notification settings - Fork 28
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
Swap predicates for updateable optional values in 'ensure' and 'validation' #33
Swap predicates for updateable optional values in 'ensure' and 'validation' #33
Conversation
Please update the tests as well. |
ah these tests weren't caught by building |
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.
This is great, thanks! ❤️
validate e p a = | ||
if p a then _Success # a else _Failure # e | ||
validate :: Validate v => e -> (a -> Maybe b) -> a -> v e b | ||
validate e p a = case p a of |
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.
Why not maybe (_Failure # b) ((#) _Success) . p
? Just out of interest, I'm only a tourist in this repo 😊
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 did think about this variation first, but I decided against it because it doesn't bring much to the code. It doesn't pass my personal golfing threshold of "is this more elegant than a pattern match?", and it also wasn't idiomatic when compared to the rest of the code.
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.
That's fair! I'd go for a birdie and write maybe (_Failure # e) (\b -> _Success # b) . p
but this version is also readable and elegant 💯
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.
a birdie 😆
Discussion here: #32
Also, found some unused imports