import { Future } from './Future' ; import { chain } from './chain' ; import { map } from './map' ; name export function sequence < A , B > ( futures ) { let seed = Future . of < Array < B > , A > ( [ ] ) ; for ( let i = 0 ; i < futures . length ; ++ i ) { const future = futures [ i ] ; seed = chain ( values => map ( value => values . concat ( value ) , future ) , seed ) ; } return seed ; }