Skip to content

Add a Result<TError> for non-value-producing operations that might fail.  #60

Description

@tshowers-bt

Currently the lib has Maybe<T> for expressions that may or may not produce a T, and Result<T, TError> for expressions that will either produce a T or fail and produce a TError. For cases that produce no value on success but may fail we use Result<T=None, TError> but there's not really any reason to interact with the None on the consumer side of a Result<None,>. Perhaps a Result<TError> type could be implemented as Result<T=None, TError> to maintain the semantics of Result<,> handling and reduce the (admittedly, very miniscule amount of) boilerplate.

The proposal is essentially Maybe<T> where T represents an error type. Result<TError> is suggested over using Maybe<T where T represents an error type because the semantics of Maybe<> and Result<,> handling both already exist, and differ. It would be fair argue that Maybe<SomeError> represents a value that may be a SomeError, but I would argue that dealing with values VS dealing with errors is a significant enough difference to warrant distinct semantics especially since we already have the concept of Result<,>.

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