gcanti / fp-ts

Functional programming in TypeScript
https://gcanti.github.io/fp-ts/
MIT License
10.78k stars 502 forks source link

Sequencing is incompatible with array.map #1921

Open hesxenon opened 8 months ago

hesxenon commented 8 months ago

🐛 Bug report

Current Behavior

Using task sequencing yields a readonly array which is incompatible with array mapping

Expected behavior

Sequencing Tasks should work with Array mapping.

Reproducible example

https://codesandbox.io/p/sandbox/fp-ts-sequencing-readonly-kndpz5?file=%2Fsrc%2Findex.ts

Suggested solution(s)

Either make it so that task sequencing does not produce readonly arrays or make the array module compatible with readonly arrays.

Additional context

It seems that there's an effort going on to move sequencing logic to use readonly arrays. While I'm ofc in favor of immutability where possible I don't think using readonly here adds any benefit to fp-ts. Even if I wanted to mutate the returned array, that should be my prerogative as a dev and it should not impact fp-ts in any way.

Your environment

Which versions of fp-ts are affected by this issue? Did this work in previous versions of fp-ts?

Software Version(s)
fp-ts 2.16.2
TypeScript 5.3.3