Giter Site home page Giter Site logo

Have you looked at rumonade? about monadic HOT 2 CLOSED

ms-ati avatar ms-ati commented on May 29, 2024
Have you looked at rumonade?

from monadic.

Comments (2)

pzol avatar pzol commented on May 29, 2024

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.

ms-ati avatar ms-ati commented on May 29, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.