"are there “type-level combinators”? will they exist in some future?" Code Answer


your question makes sense, but the answer is: no, it's not currently possible.

the problem is that (in ghc haskell's type system) you can't have lambdas at the type level. for anything you might try that looks like it could emulate or achieve the effect of a type level lambda, you will discover that it doesn't work. (i know, because i did.)

what you can do is declare your flip newtypes, and then write instances of the classes you want for them, painfully with the wrapping and the unwrapping (by the way: use record syntax), and then clients of the classes can use the newtypes in type signatures and not have to worry about the details.

i'm not a type theorist and i don't know the details of why exactly we can't have type level lambdas. i think it was something to do with type inference becoming impossible, but again, i don't really know.

By feiiiiii on July 5 2022

Answers related to “are there “type-level combinators”? will they exist in some future?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.