-
Notifications
You must be signed in to change notification settings - Fork 0
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
prep-5.0 #2
Conversation
@jrstrunk Would you be so kind and could do a brief review. I'd be so glad. |
src/given/lib/optionx.gleam
Outdated
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 use this same convention! When I want to add functionality to a package, I create a new one in my project with an 'x' suffix, just like this 'optionx' module.
Just want to ask though, will this end up in given's public API?
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 generated the docs and it does make it into the public API! Wouldn't we want this to be private?
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 use this same convention! When I want to add functionality to a package, I create a new one in my project with an 'x' suffix, just like this 'optionx' module.
Just want to ask though, will this end up in given's public API?
I had it internal first. I can move it back there again.
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.
The x stands for extended... and I namespaced it into the package.
return consequence: fn() -> a, | ||
else_return alternative: fn() -> a, | ||
) -> a { | ||
pub fn that( |
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 like this change for the qualified use case
This looks really nice! The checks for empty lists are really nice, too. The only thing I might ask to consider again is the inclusion of Do you think there is a real need for the With this release, I think the library is at a really good size—just enough functionality to be worth the dependency, but not so much that it takes a while to learn. |
So I know from studying a bit of (Cognitive) Psychology but also practise that negation is bad if it can be avoided. I am happy that Elixir is removing That being said, whenever you do want to reach for the negation I think going for the other label/callback is not what I would recommend. These labels are there for consistency and to give people options but not as a recommendation. I still think it reads much better to write a not and then know the rest is negated. use <- given.not(is_admin, else: fn() { noop() })
// long handling of how to ugrade a user to an admin versus use <- given.that(!is_admin, else: fn() { noop() })
// long handling of how to ugrade a user to an admin I prefer the not-variants by far. 2 cents: I also think that gleam "should" have used So I removed some duplication and recommended unqualified imports but the not variants will stay. No one is forced to use them and they read much better than "unless" or "!" IMHO. |
As for the size, I do not plan to add more for now, as I also thought: I do not want to create a DSL. |
Since the args can be flipped, aren't these the same: use <- given.not(is_admin, else: fn() { noop() })
// long handling of how to upgrade a user to an admin use <- given.that(is_admin, return: fn() { noop() })
// long handling of how to upgrade a user to an admin If they are the same, isn't the second preferable? |
The mind model I was following was that for boolean and list of boolean guards The default case for booleans is For The other labels are there to give people options if they desire to do so, like you seem to. |
Would you prefer given.non_empty or given.not_empty? |
Okay, then leaving it as is is fine with me! Users can choose how to use it. I like the |
I am torn because the rest is named not and suddenly you need to use non, but non-empty-list is a well known term 🤷🏼 |
Yeah, I understand that dilemma, haha. I still like "non-empty" because as you said it is a well-known term and for me it carries less mental overhead than "not empty." |
like not-empty could be a string, but non-empty revers to a list usually? |
No description provided.