fp-ts
fp-ts copied to clipboard
Reduce suspension in Task to preserve order
closes #1626
Not 100% this is stack safe in any case but it appears to be so
I am kind of surprised by this but what seems to be affecting is the suspension of map
, namely:
export const map: <A, B>(f: (a: A) => B) => (fa: Task<A>) => Task<B> = (f) => (fa) => () => fa().then(f)
this is fine while:
export const map: <A, B>(f: (a: A) => B) => (fa: Task<A>) => Task<B> = (f) => (fa) => () => Promise.resolve().then(() => fa().then(f))
inverts the execution order