Skip to content
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

Merged
merged 3 commits into from
Apr 18, 2019

Conversation

emilypi
Copy link
Contributor

@emilypi emilypi commented Mar 26, 2019

Discussion here: #32

Also, found some unused imports

@gwils
Copy link
Collaborator

gwils commented Mar 26, 2019

Please update the tests as well.

@emilypi
Copy link
Contributor Author

emilypi commented Mar 26, 2019

ah these tests weren't caught by building all. My bad.

Copy link

@FintanH FintanH left a 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
Copy link

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 😊

Copy link
Contributor Author

@emilypi emilypi Mar 26, 2019

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.

Copy link

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 💯

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a birdie 😆

@gwils gwils merged commit d115201 into system-f:master Apr 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants