First of all I really like this write-up. It demonstrates a very useful functional programming pattern! But did notice that instead of using fold to transform the Either<Errors, T> into Either<Error, T>, you could use mapLeft. I doubt it would ever matter in practice, since this is not a tight loop, but mapLeft is more efficient since it doesn't construct a second Right value every time it succeeds. Other than that (and the fact that the code is now out of date with the library API), this is super good!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
First of all I really like this write-up. It demonstrates a very useful functional programming pattern! But did notice that instead of using
fold
to transform theEither<Errors, T>
intoEither<Error, T>
, you could usemapLeft
. I doubt it would ever matter in practice, since this is not a tight loop, butmapLeft
is more efficient since it doesn't construct a secondRight
value every time it succeeds. Other than that (and the fact that the code is now out of date with the library API), this is super good!