-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
Change toMaybe API to work more like encase #465
Comments
I'm not sure that You mention the possibility of providing S.toMaybe3(f) is less noisy than… (x, y, z) => S.toMaybe(f(x, y, z)) As of #418, though, Sanctuary no longer includes any functions which take uncurried functions, so one would first need to curry S.toMaybe3(S.curry3(f)) One of the things I dislike about Ramda is that it provides so many functions for interoperating with unprincipled JavaScript functions. I'd prefer to provide a minimal set of tools and let users wrap unprincipled functions manually. In my experience manual wrapping is helpful as I often find myself wanting to curry a function and reorder its parameters in addition to changing its return type. |
This idea came in response to my observation that new Sanctuary users often simply replace code like this: function getX(){ Math.random() > .2 ? 'x' : null }
var x = getX() || 'default value'; With code like this: function getX(){ Math.random() > .2 ? 'x' : null }
var x = S.fromMaybe('default value', S.toMaybe(getX())); The latter clearly having no advantages; Failing to (realize that they should) address the source of the Changing the Though you have compelling counter-arguments. I just posted this not to lose the idea. Feel free to close it if you prefer keeping things the way they are. :) |
Your concern is significant. I do wonder whether it would be better addressed by mentioning the |
I'd vote for eliminating |
That's a good option, Gabe. I could get behind that. :) |
From our Gitter conversations:
The text was updated successfully, but these errors were encountered: