Convert Array of Either<E,A> to Either<E,A[]> (sequence function in Scalaz)
To go from Array<Either<L, A>>
to Either<L, Array<A>>
you can use sequence
:
import { array } from 'fp-ts/lib/Array'
import { either } from 'fp-ts/lib/Either'
array.sequence(either)(arrayOfEithers)
Your example can also be further simplified using traverse
array.traverse(either)(['1','2','3'], NumberFromString.decode)