我想出了以下内容。
import {pipe} from 'fp-ts/lib/function'
import { getFoldableComposition } from 'fp-ts/Foldable'
import { array } from 'fp-ts/Array'
import { option,fromNullable } from 'fp-ts/Option'
import { monoidSum } from 'fp-ts/Monoid'
const F = getFoldableComposition(array, option)
let c1 = fromNullable(10)
let c2 = fromNullable(20)
let c3 = fromNullable(undefined)
let c4 = fromNullable(undefined)
// returns 30
F.reduce([c1,c2],0, monoidSum.concat) //?
// alternatively, also returns 30
F.reduce([c1,c2],0, (i,j)=>i+j) //?
// The above unwarp the result though. To return as the monad need to lift the result
// returns some(30)
pipe(F.reduce([c1,c2],0, (i,j)=>i+j), fromNullable) //?
// returns some(0)
pipe(F.reduce([c3,c4],0, (i,j)=>i+j), fromNullable) //?