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

Nice, convenient and idiomatic way to handle Maybe's #15

Closed
chshersh opened this issue Oct 26, 2016 · 3 comments
Closed

Nice, convenient and idiomatic way to handle Maybe's #15

chshersh opened this issue Oct 26, 2016 · 3 comments
Assignees

Comments

@chshersh
Copy link
Contributor

chshersh commented Oct 26, 2016

I propose to add next operators in Universum to work with Maybe in even more nice way:

(?:) = flip fromMaybe  -- elvis operator

m !!: s = m ?: error s  -- unsafe elvis operator

(?.) = (>>=)  -- specialisation for Maybe

So it should be possible to write code like this one:

tail args?.head?.readMaybe ?: 0

@chshersh
Copy link
Contributor Author

chshersh commented Jul 7, 2017

Also consider this (I'll just put it here):

https://twitter.com/Iceland_jack/status/883314861924593664

@vrom911
Copy link
Contributor

vrom911 commented Dec 18, 2017

@chshersh , I like (?:) option 💯
But I'm not sure that introducing the pattern for Maybe constructors would be great thing to do.. 🤔

@chshersh
Copy link
Contributor Author

I don't think we need to have ?. operator. >>= is more common and known to people. Though, ?: looks idiomatic. We don't want to have partial functions in universum so I don't think we need to have :!!.

@chshersh chshersh added this to the v1.2.0: Convenience milestone Feb 10, 2018
vrom911 added a commit that referenced this issue Feb 19, 2018
vrom911 added a commit that referenced this issue Feb 19, 2018
chshersh added a commit that referenced this issue Feb 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants