Skip to content

Commit a98cf0c

Browse files
authored
Make updates for polykinds (#312)
1 parent f6dbb2f commit a98cf0c

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

language/Types.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ The inferred type of ``addProps`` is:
109109
forall r. { foo :: Int, bar :: Int | r } -> Int
110110
```
111111

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.
113113

114114
In other words, ``addProps`` accepts any record which has properties ``foo`` and ``bar``, and *any other record properties*.
115115

@@ -154,7 +154,7 @@ since the rigid type variable ``a`` — that is, the type variable bound by the
154154

155155
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)``.
156156

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.
158158

159159
To denote a closed row, separate the fields with commas, with each label separated from its type with a double colon:
160160

@@ -238,18 +238,24 @@ equal1 = one :: forall a. Semiring a => Eq a => a
238238

239239
## Kind System
240240

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:
242242

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
247247
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+
```
249252

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:
251254

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.
255+
```purescript
256+
proxy :: forall k (a :: k). Proxy a
257+
proxy = Proxy
258+
```
253259

254260
## Quantification
255261

0 commit comments

Comments
 (0)