Railway Oriented Programming
Inspired by F# Railway Oriented Programming article https://fsharpforfunandprofit.com/rop/
from rop.result import Result
def func_example():
result = does_file_exist() \
.on_success(parse_log()) \
.on_success(store_to_database()) \
.on_success(finalize_report())
if result.is_success:
print('Successfull!')
else:
print(result.error_text)
def does_file_exist() -> Result:
return Result.ok()
def parse_log() -> Result:
return Result.ok()
def store_to_database() -> Result:
return Result.fail('Database error!')
def finalize_report() -> Result:
return Result.ok()