DigitecGalaxus / DigitecGalaxus/Galaxus.Functional
Add a way to convert an Option<T> to an Either<A, T>
- Dominant language
- C#
- Stars
- 41
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
With `Option.ToEither(B)` there is a way to convert an Option to an Either with a fallback value. The drawback is, that the Option's value will always be in the A spot and the fallback value in the B spot.
The order of the A, B, (and C) in an Either have no intrinsic semantic meaning. Therefore there exist legitimate cases, where you have an interface, requiring a parameter of type `Either` that you would like to call from an `Option` or an `Either`.
To achieve this, there are multiple solutions:
1. Introduce a method e.g. `Swap()` on `Either` returning an `Either`
2. Introduce two methods on an `Option`: `AsA(B valueIfNone)` returning an `Either` and `AsB(A valueIfNone)` returning an `Either`
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the existing Option.ToEither(B) conversion and the Either API. Compare the proposed Swap() and AsA/AsB approaches, then establish which API should support the requested type ordering; done means the selected conversion is available for the described Option and Either use cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100