4 ms·
Couldn't I just return a tuple instead if I wanted to give the caller information on the nature of the success or failure? Also, both Django and SQLAlchemy thr
by Karunamon 5y ago
Couldn't I just return a tuple instead if I wanted to give the caller information on the nature of the success or failure?
Also, both Django and SQLAlchemy throw proper exceptions on bad queries or DB errors, which is probably the right thing to do in the average app using these libraries (the exception bubbles up, getting logged, returning the appropriate http error, etc).
I'm not crapping on this library, mind, I just can't find the use case that justifies it.
- linkdd 5y agoIt's about function composition. How do you compose a function that returns an int or an error with a function that takes an int as parameter? Yes you can split this in multiple steps, or you can use monads to handle the composition for you, making you type less code, giving more information to the typesystem (mypy for python for example) about what is valid and what's not. This is a completely different programming style, it's functional programming, aka: "how to make functions by composing other functions".