Skip to content

Latest commit

 

History

History
42 lines (28 loc) · 771 Bytes

README.rst

File metadata and controls

42 lines (28 loc) · 771 Bytes

rop

Railway Oriented Programming

Description

Inspired by F# Railway Oriented Programming article https://fsharpforfunandprofit.com/rop/

Usage

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()