A linear type tracks the so called multiplicity of some data. Linearity polymorphism is connected to linear types, aka types that track "usage" of data. And because it only defined in the scope of the stateful action (by the inner forall), every attempt at leaking anything from the computation is an error in the compiler. As we do not specify any constraints on what the s is, the stateful computation cannot do anything with it except passing it around in the type signatures. You can see that s is created using higher-rank polymorphism. The best example is the Proxy data type in Haskell. Kind polymorphism is when you can define a type only once but still use it with multiple kinds. If you give List another type (for example Int) you get a new type ( List Int). Therefore its kind is List :: Type -> Type. For example while our list type earlier is a type ( List a), what is List (without the a)? It still needs another type as argument to form a normal type. So this means 5 :: Int :: Type ( :: means "has type"). The kind of all types is Type also written as *. But there is even a level above that: Kinds. ![]() The types of the three values before are Int, String and Bool. This should also be very known to programmers. Then there is the type level, describing values. ![]() 5, "foo", false are all examples of values. We all know values, it's the data that every function deals with. One of the most popular languages implementing row polymorphism is PureScript and I am also currently working on bringing it to Haskell. ![]() Const driveToyota = ( c : Toyota ) => -> String`
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |