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

Add maybe utils #658

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Conversation

TimWhiting
Copy link
Collaborator

@TimWhiting TimWhiting commented Jan 11, 2025

A few updates to the standard library for maybe. Open to feedback / suggestions.

I've improved the error location for the unjust function. I also renamed unjust2 to unjust, since none of the other functions in core/maybe2 use the 2 qualifier, and we have static overloading which can resolve this most of the time.

I then also added an expect function which expects an explicit error message as a second parameter.
This mimics the naming of this function in Rust's Option type, but I'm open to other names.

If we go with Rust's naming for this it might be good to look at also changing unjust to unwrap - maybe with a deprecation notice on the old definition due to it's wide use. Haskell uses fromMaybe, Swift uses a postfix ! and unsafelyUnwrap for no runtime checks in non-debug builds.

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.

1 participant