Hacker News new | past | comments | ask | show | jobs | submit login
Python Functional Programming with returns library (type-safety, monads, etc.) (github.com/dry-python)
12 points by behnamoh on Feb 19, 2024 | hide | past | favorite | 3 comments



My team has just spent 20 minutes trying to work out if this library is satire.

I love functional programming (use Elixir at work a fair amount), but almost every one of these examples is harder to read than than the equivalent "classic" Python (https://returns.readthedocs.io/en/latest/).

Plus, if you're going to write Python then deviating majorly from the normal approaches is going to require maintainers to learn a whole new way of doing things. Given the tools that Python provides, I don't think that's worth it for the benefit. Perhaps for some specific applications?


Your last point really resonated on the Django example for RequestContext - the entire point of using a framework is taking advantage of the set of tools and conventions it provides, and that code is basically reinventing the Django settings module. It’s almost always going to be better to write the simple standard code, or to pick an example which doesn’t start with an incorrect assertion to justify the extra complexity it’s adding. It does also make me wonder whether part of the problem is that they’re not used to a language with keyword arguments - passing a single parameter through a nested function call really shouldn’t get that strong negative reaction.

In general, this reminds me of the common problem where people assume their code will be reused far more often than it actually is and try to write code like the frameworks they’ve learned without considering whether they have the same resources to develop their new bespoke framework.


Yeah, all the examples leave quite a bad impression on me. But I suspect that is mostly down to python being, well, python.

But I am probably biased because I prefer the ML family of languages for FP.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: