// @flow import type { Applicative } from './Applicative' import type { Semigroup } from './Semigroup' import type { Either, EitherF } from './Either' import * as either from './Either' export function getApplicative(semigroup: Semigroup): Applicative { function ap(fab: Either B>, fa: Either): Either { const ab = either.prj(fab) const a = either.prj(fa) if (ab instanceof either.Left && a instanceof either.Left) { return either.left(semigroup.concat(ab.value0, a.value0)) } return either.ap(fab, fa) } return { map: either.map, ap, of: either.of } }