You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: language/Types.md
+16-10Lines changed: 16 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,7 +109,7 @@ The inferred type of ``addProps`` is:
109
109
forall r. { foo :: Int, bar :: Int | r } -> Int
110
110
```
111
111
112
-
Here, the type variable ``r`` has kind ``# Type`` - it represents a row of types. It can be instantiated with any row of named types.
112
+
Here, the type variable ``r`` has kind ``Row Type`` - it represents a row of types. It can be instantiated with any row of named types.
113
113
114
114
In other words, ``addProps`` accepts any record which has properties ``foo`` and ``bar``, and *any other record properties*.
115
115
@@ -154,7 +154,7 @@ since the rigid type variable ``a`` — that is, the type variable bound by the
154
154
155
155
A row of types represents an unordered collection of named types, with duplicates. Duplicate labels have their types collected together in order, as if in a ``NonEmptyList``. This means that, conceptually, a row can be thought of as a type-level ``Map Label (NonEmptyList Type)``.
156
156
157
-
Rows are not of kind ``Type``: they have kind ``# k`` for some kind ``k``, and so rows cannot exist as a value. Rather, rows can be used in type signatures to define record types or other type where labelled, unordered types are useful.
157
+
Rows are not of kind ``Type``: they have kind ``Row k`` for some kind ``k``, and so rows cannot exist as a value. Rather, rows can be used in type signatures to define record types or other type where labelled, unordered types are useful.
158
158
159
159
To denote a closed row, separate the fields with commas, with each label separated from its type with a double colon:
160
160
@@ -238,18 +238,24 @@ equal1 = one :: forall a. Semiring a => Eq a => a
238
238
239
239
## Kind System
240
240
241
-
The kind system defines the following kinds:
241
+
The kinds of types are other types. The only types that are not supported in kinds are constraints, which have no kind-level equivalent. Kind polymorphism is supported through top-level kind signatures for ``data``, ``type``, ``newtype``, and ``class`` declarations:
242
242
243
-
-``Type``, the kind of types.
244
-
- Arrow kinds ``k1 -> k2``
245
-
- Row kinds ``# k``
246
-
- User-defined kinds, such as ``Control.Monad.Eff.Effect``, the kind of effects.
243
+
```purescript
244
+
-- Defined in Type.Proxy
245
+
data Proxy :: forall k. k -> Type
246
+
data Proxy a = Proxy
247
247
248
-
## Row Kinds
248
+
proxy1 = Proxy :: Proxy Int -- k is Type
249
+
proxy2 = Proxy :: Proxy "foo" -- k is Symbol
250
+
proxy3 = Proxy :: Proxy (foo :: Int, bar :: String) -- k is Row Type
251
+
```
249
252
250
-
The kind ``# k``of rows is used to classify labelled, unordered collections of types of kind ``k``.
253
+
In type signatures, kind variables are quantified with ``forall``like other type variables. Polymorphic kinds must be quantified before any kind annotated variables that reference them:
251
254
252
-
For example ``# Type`` is the kind of rows of types, as used to define records, and ``# Control.Monad.Eff.Effect`` is the kind of rows of effects, used to define the monad ``Control.Monad.Eff.Eff`` of extensible effects.
0 commit comments