简体   繁体   中英

The kind literal in Haskell

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?

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 forall a b. /\\c. a -> b -> c 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM