Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The thing is, it takes a bit of experience to appreciate why HKT are important, and typically you can only get this experience using Haskell.

There’s a couple of ways to think about it: it gives you a way to talk about List rather than List of T, it enables you to write partial types like partially-applied functions, or it makes it possible to define Monads.

But as I say, none of these things will sound immediately useful unless you have experience of using those concepts already.



I think there is a certain kind of programmer who enjoys the aesthetics of higher-kinded types, and after having made the investment to truly grok them, wants these HKTs to also be useful in practice.

I don’t think the benefit ever materializes and highly abstract code is just indulgence.

Much like the people who endlessly tinker with their IDE/emacs/desktop environment/shell in the name of productivity.


Honestly, they are useful in practice, as long as you’re using a language that supports them properly (I’m not convinced TS is that language). Even without, they constitute a pattern that is very simple to implement which is very powerful.

People believed (and some still do believe) the same thing about generics.


true


Other than Monads, HKT can be used to easily write type-level functional programs [1]. This can for example help writing type-level parsers for other lanugages.

A real world use-case could be parsing GraphQL raw string queries and automatically infer the returned types based on a common schema, without using special code-generators. For instance you can come up with some magic function `gql_parsed` like:

doc = gql_parsed`query GetUser { user { name }}`

where doc is inferred as something like Doc<Query<{GetUser:{user:{name:string}}}>>

[1] https://desislav.dev/blog/tsfp/


> The thing is, it takes a bit of experience to appreciate why HKT are important, and typically you can only get this experience using Haskell.

They're fairly common in Scala too, and I believe in OCaml through modules.


And C++ if you squint hard enough.


and F# with computations Seems common with functional programming, that it takes a mind-set change before seeing the need.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: