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?
A literal is a more concrete sub-type of a collective type. What this means is that "Hello World" is a string , but a string is not "Hello World" inside the type system.
The values assigned to each constant variable are referred to as the literals. Generally, both terms, constants, and literals are used interchangeably. For example, “const int = 5;“, is a constant expression and the value 5 is referred to as a constant integer literal.
The string literal type allows you to specify a set of possible string values for a variable, only those string values can be assigned to a variable. TypeScript throws a compile-time error if one tries to assign a value to the variable that isn't defined by the string literal type.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With