I am still learning and playing with fp-ts and can't figure this out.
I have an array of Either<any, number>[]
and I would like to get an Either<any, number[]>
.
I have looked at Apply.sequenceT
and the example sequenceToOption and it looks close.
import { NumberFromString } from 'io-ts-types/lib/NumberFromString'
import { Either } from 'fp-ts/lib/Either'
const a:Either<any,number>[] = ['1','2','3'].map(NumberFromString.decode)
console.log(a)
// [ { _tag: 'Right', right: 1 },
// { _tag: 'Right', right: 2 },
// { _tag: 'Right', right: 3 } ]
I want instead either an error or array of numbers.