|
|
|
|
|
by evolveyourmind
1105 days ago
|
|
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/ |
|