2 ms·
"A type that accepts types that generates another type" is called a type constructor. And a "kind" is the type of a type constructor, just to have a new name an
by ReleaseCandidat 3y ago
"A type that accepts types that generates another type" is called a type constructor. And a "kind" is the type of a type constructor, just to have a new name and not needing to call that "type" too.
"Generic types" like `Vec<T>` (in Rust) are type constructors, they "generate" a type `Vec<T>` from the type `T`. Type constructors that take one type as argument have the kind `* -> *` (or as Rust-y notation `fn(*) -> *` - read each asterisk as "type". Type constructor that take two types arguments have the kind `* -> * -> *` (Rust-y: `fn(*, *) -> *`).
A higher (-order) kinded type takes (for example) a type constructor (here a type constructor which takes just one argument) and generates a type from it: `(* -> *) -> *` (Rust-y: `fn(fn(*) -> *) -> *`.
Edit: I hope now all asterisks are properly escaped ...
- ReleaseCandidat 3y agoEdit2: oh, I guess misunderstood "A type that accepts types that generates another type". If you meant to say "A type that accepts (types that generates another type)", so a type constructor that accepts type constructors and not "(A type that accepts types) that generates another type", which is a type constructor.
- chrisweekly 3y agoYeah, I think "types that generateS" is either a typo or sloppy English; it should be "types that generate". I often wonder why it's so common for programmers with an acute awareness and mastery of syntax and grammar in programming languages to just throw all that precision and attention to detail out the window when it comes to natural language.