Implement Sequence method for Either type only #44
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
Coming from a fp-ts background, I'm accustomed to be able to perform operations like sequenceT:
In other words, maybe I need to hit an API multiple times with a bunch of inputs, so this is an array of TaskEithers, but at the end of the day, I just want to abstract that out, await this task once, and get back the array of responses.
I looked through the library for quite a long time and couldn't find anything like that in there yet, so I presumed that it's either called something else, or can be constructed somehow using Dart type magic, or just hasn't been implemented yet.
Approach
I'm quite new to Dart and am not fully up to speed with the Type system yet.
My understanding is that a better long-term solution is to implement some kind of abstract interface for sequence, then each type (like Either, TaskEither, Option etc) would provide some kind of method for how to implement a particular step in the sequence combinator.
I don't know how to do this yet, and also for my project I just need to unwrap Lists of Eithers at the moment. So I will be using this function in my code until this has been resolved in this project.
It's more of a suggestion at this stage, and I'm happy to take some feedback as to how to better integrate this feature into the package and work on a more comprehensive solution.