It still has exceptions- but exceptions are normal. Errors are normal.
How would one do : https://fsharpforfunandprofit.com/rop/ in python?
I tried it once in an sqlite DB connector with some business logic and simply checking stuff like
res: DBException | Result = db_handler.some_business_logic()
if isinstance(res, DBException):
return res # you can also log or even raise if this function isn't returning exceptions as values
# guaranteed to be Result type here
See here:- https://gitlab.com/meehai/drpciv-flask/-/blob/main/be/db_han...
- https://gitlab.com/meehai/drpciv-flask/-/blob/main/be/app.py...
I wrote a small utility library for exactly that kind of "railway oriented programming" if you're curious about what it'd look like in python: https://github.com/benrutter/ufo-tools