gcanti / fp-ts

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

How to replace deprecated Function1 and Curried2? #951

Closed bepremeg closed 4 years ago

bepremeg commented 4 years ago

🐛 Bug report

Current Behavior

Since version 1.6.1 Function1, Function2, etc are deprecated. The docs don't specify what should be used instead (or that usage should be dropped entirely).

Since at the same time FunctionN was introduced, one could assume that this is the preferred substitution. Even though type signatures now look weird to me, it's a taste that could be acquired I guess.

However, we also regularly use Curried2 and friends. What should we replace this with?

This would have a significant impact on our migration effort to v2. Though we could obviously still provide our own implementations of Function1, Curried2, etc.

I do notice that the fp-ts implementation itself does not use the Function1, Curried2 family. What is the thinking behind using or not using this kind of type signatures?

I personally like the separation between argument types and names it provides. What is indeed annoying is that adding an argument implies increasing a number. It also doesn't play nice with generic arguments. However, this is only an issue in a minority of cases.

gcanti commented 4 years ago

However, we also regularly use Curried2 and friends. What should we replace this with?

The curry function doesn't play well with polymorphic functions, so was dropped along with the related Curried family