Hacker News new | ask | show | jobs
by nostrademons 4316 days ago
It does get better - write a lot of code with the new language features and you'll get a sense when they're not useful, or how you can apply them to more mundane languages. You can define a decorator in Python to do Maybe monads, for example:

  def maybe(decorated):
    def worker(*args):
      if any(arg is None for arg in args):
        return None
      return decorated(*args)
    # Standard decorator machinery
    return worker
(This doesn't mean you should; this usage is pretty non-idiomatic and will do strange things in edge-cases. That's my point though...the only way to figure out when it's worth it is to try it out in a few situations and determine when it makes the code simpler.)