sherry-ummen / rop

Python Railway Oriented Programming

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Python Railway Oriented Programming

License:MIT License


Languages

Language:Python 100.0%