DEV Community

Discussion on: Option: fp-ts

 
waynevanson profile image
Wayne Van Son

HKT is not about composition but about code reuse and pattern reuse

I feel like pattern reuse is composition, which means that HKT is compositional by nature.
How would you define composition?

F# has no HKT.

That's correct, sorry about that. I don't know F# very well, but it looks like it has HKT because it's got the Async<T> type and it has methods, just like a typeclass, to manipulate code in async world. Thanks for mentioning this.

Again you can make these abstractions without HKT

We can, such as with fluture: lazy promises.

I really don't need HKT in a language which doesn't support it. HKT fits great where it is idiomatic so in Haskell or PureScript. TypeScript not support HKT, and what fp-ts is doing is a hack.

The "hack" is what makes it special. If it wasn't we'd just use purescript.
I feel like more people move to fp-ts than to purescript because being close to the javascript specification is important.
Maybe because it's familiar, maybe because it drives the internet, maybe because it integrates well into existing codebases.
People and companies are seeing use cases which require these compositional aids. Grammarly is just one of them, which they did a talk on describing their use case.