fp-ts icon indicating copy to clipboard operation
fp-ts copied to clipboard

pipe and bracket

Open jamiehodge opened this issue 2 years ago • 1 comments

🚀 Feature request

Current Behavior

Currently, bracket's signature is (acquire, use, release) => { ... }

Desired Behavior

Looking at https://wiki.haskell.org/Bracket_pattern, the signature there is (acquire) => (release) => (use) => { ... }. That appears to be more easily pipeable and avoids having the annotate the type of use.

Suggested Solution

Please consider a breaking change as a part of your 3.0 work to the more Haskell-like signature.

Your environment

Software Version(s)
fp-ts 2.11.7
TypeScript 4.5.4

jamiehodge avatar Jan 27 '22 07:01 jamiehodge

By how TS inference work the only pipeable would be: (use, release) => (acquire) => ... to be used like pipe(doBla, blaBla, bracket(use, release))

That's because release needs the types from use and acquire while use only needs (but still needs) the types from acquire.

mikearnaldi avatar Feb 04 '22 09:02 mikearnaldi