gcanti/fp-ts-contrib

Extend TaskOption from Alt1 to Alternative1

pbadenski opened this issue ยท 4 comments

๐Ÿš€ Feature request

Current Behavior

Currently TaskOption implements Alt1.

Desired Behavior

Add zero to TaskOption to implement Alternative1.

Suggested Solution

const zero = getOptionM(..).none

Who does this impact? Who is this for?

People using Applicative interface.

Your environment

Software Version(s)
fp-ts 2.0.1
fp-ts-contrib 0.1.14
TypeScript 3.6

What do you think of changing OptionT first to implement Alternative1? Then adding zero via T.zero (where T = getOptionM(task))?

@pbadenski what do you mean? Isn't zero = T.none?

Sorry, I haven't really explained this well.

At the moment taskOption has:

map:   T.map,
ap:    T.ap,
chain: T.chain,
alt:   T.alt,

To add zero to the above list in taskOption we could do two things.

  1. Add zero = T.none.
  2. Or add zero to OptionT first and then in TaskOption have zero = T.zero.

Option already has both none and zero. In 2. option there would be then full symmetry between Option, OptionT & TaskOption.

I suppose, now that I think about it - starting with 1. is probably better for backwards compatibility and rolling this change out.

starting with 1. is probably better for backwards compatibility and rolling this change out

๐Ÿ‘