Skip to content

Add Either monad #23

Description

@bartsokol

Result is great for handling typical Ok/Error scenarios, but in some cases, some more flexibility could be helpful - like having an option to specify type returned in both cases.

Let's add Either type (or Choice as it is known in F#) with two values, Left and Right (as they are often named in the implementations). I would restrain from using F# names in this case (Choice1of2 is kind of weird).

The set of extensions for this type can be based upon, but will probably differ from, Result and Option types. It would be good to discuss here which methods would be useful in this case. For now, I would skip *Async variants and see how it goes (they may be added in next release if needed).

The structure for this type should be kept as it is for Result type in version 0.3 (soon to be released), so separate file for the type and then for extensions. Of course, all the extensions should be covered by the unit tests.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions