Skip to content

Flow & bind functions #146

Open
Open
@minmax

Description

What do u guys think about adding some helpers functions like flow & bind, just like returns already has?

I try to use them and imho its looks better then chain of .and_then().and_then().

result: Result[int, ValueError] = flow(
    "1",
    bind(str_to_float),
    bind(float_to_int),
)

def str_to_float(s: str) -> Result[float, ValueError]:
    ...

def float_to_int(f: float) -> Result[int, ValueError]:
    ...

I don't test my code on mypy, but pyright is ok with types of flow & bind, so i think its possible to adapt.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions