Comments (2)
Hi Marc, I actually discovered it after posting this gem to github. I am pretty impressed by the work you have done.
You have very well implemented it in the way a monad should be implemented, besides that the Monad module needs to be included after defining bind - I think this can be better solved with inheritance maybe.
I am trying to create something more idiomatic to ruby. Hence #value instead of #get_or_else. Also doing subsequent map, select etc is very functional but my primary idea was to safely support (trainwreckish) expressions like
User.name.capitalize. Also I often work with nested Hashes and need to reach deeply inside of them so my code is sprinkled with things like some_hash.fetch(:one, {}).fetch(:two, {}).fetch(:three, "unknown").
With the method_missing on None I can safely and consisely do:
some_hash.[:one][:two][:three].('unknown') or with injecting a method_missing into hash even better:
some_hash.one.two.three. 'unknown' or some_hash.one.two.three.or 'unknown' or some_hash.one.two.three.value 'unknown'
from monadic.
Thanks Piotr, sounds like you have different goals then. Because of how dynamic Ruby is, I wanted my code to be very clear and obvious when you have an Option, and when you have the underlying value. But your approach may be very popular, as I've seen a lot of code that seems to want to do what you are trying to do. Good luck!
from monadic.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from monadic.