Skip to content

Helpers for turning partial functions into a Result/Either #878

Description

@enolive

this library looks very intriguing and I am thinking of using it.

it seems to be in the perfect sweet spot between something a bit too basic (CSharpFunctionalExtensions) and almost haskell-ish (language-ext).

but what surprises me is that I cannot find any functions to construct an Either/Result out of a function call

sth like

Result.Try(() => 42); // Ok(42)
Result.Try(() => throw new InvalidOperationException("BOOM")); // Error(...)
...

Similar things could be done with async functions.

Same thing with Either, but its result will be Either<Exception, T> instead of Result

Many similar libs are implementing static helpers like that.
They usually also ignore fatal errors such as OOM that should not be caught

am I missing sth in the library from my research?

I can write own helpers of course but it seems to be absurd to introduce a new library and do that as one of the first actions 😉

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions