Reputation: 601
As I know, the ->
has kind *->*->*
, and the ((->) r)
has kind *->*
.
Assuming there is a type (a->b->c)
, is there a way to represent the (a->b->)
?
I tried ((->) a ((->) b))
but it's error.
I tried:
type Kab a b c = (a -> b -> c) -- it is ok
But it is failed to use the Kab
in instance declaration:
instance KClass (Kab a b) where -- error
The only way I found that works is declare a data
:
data Kab a b c = Kab (a -> b -> c)
instance KClass (Kab a b) where ..
But if I use the data, I have to unwrap the Kab
, while my idea is to implement a KClass on native function type.
So how to do it?
Upvotes: 9
Views: 153
Reputation: 153102
It can't be done, unfortunately.
One might wish for "type-level lambdas" (let's write them /\
); then you would be able to write forall a b. /\c. a -> b -> c
to denote this. This would be a really handy feature, and there has been much study into type systems that allow this, but the price you pay is that type inference becomes undecidable. So the Haskell committee decided to skip it.
Upvotes: 10