samhh / fp-ts-std

The missing pseudo-standard library for fp-ts.
https://samhh.github.io/fp-ts-std/
MIT License
207 stars 27 forks source link

update merge fn to correct type inference with uncurry #166

Closed arrterian closed 1 year ago

arrterian commented 1 year ago

Before changes:

Screenshot 2023-02-23 at 15 22 56

After changes:

Screenshot 2023-02-23 at 15 22 30
samhh commented 1 year ago

I can see the benefit for inference there, however it breaks partial application (outside of pipelines):

const f = masterMerge({ a: 123 })
const fx = f({ b: 'abc' }) // { a: number } & { b: string }

const g = prMerge({ a: 123 })
const gx = g({ b: 'abc' }) // { a: number }
arrterian commented 1 year ago

Then how about this declaration for merge

export declare const merge: <A, B>(x: A) => <C extends B>(y: C) => A & C;

It seems to work for both cases.

samhh commented 1 year ago

Looks good, thank you!

samhh commented 1 year ago

Ah wrong base branch (not your fault). It's cherry-picked into develop.