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: docs/source/codata-types.rst
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,20 @@ That is, we use brackets and bars instead of parentheses and commas. Moreover,
32
32
It is often helpful to think of a codatatype as akin to an *interface* in an object-oriented programming language, in which case the variable ``x`` is like the ``this`` or ``self`` pointer by which an object refers to itself. Of course an interface in a simply-typed language does not need a self-pointer to specify the *types* of its methods, but in a dependently typed language it does. In higher-dimensional type theories, the presence of this variable can be used in other ways than simply accessing previously declared methods, such as in the definition of semi-simplicial types using :ref:`Displayed coinductive types`.
33
33
34
34
35
+
Self variables for record types
36
+
-------------------------------
37
+
38
+
The syntax of self variables is also available as an alternative when defining record types. For instance, the usual sort of Σ-type, as a record with eta-conversion, can also be defined by
39
+
40
+
.. code-block:: none
41
+
42
+
def Σ (A : Type) (B : A → Type) : Type ≔ sig (
43
+
x .fst : A,
44
+
x .snd : B (x .fst))
45
+
46
+
It should be emphasized that this is just a different notation for record types, not a "codatatype with eta-conversion". At present there is no practical difference, but in the future recursion will be forbidden in record types, even those that use the self-variable notation.
|SelfRecord : (Field.wrapped, 'acodatafield) Abwd.t -> 'a check
132
133
|Refute : 'asynthlocatedlist* [ `Explicit|`Implicit ] -> 'a check
133
134
|Hole : {
134
135
scope : 'aI.scope;
@@ -302,6 +303,8 @@ functor
302
303
|Codata : (Field.wrapped, 'acodatafield) Abwd.t -> 'a check
303
304
(* A record type binds its "self" variable namelessly, exposing it to the user by additional variables that are bound locally to its fields. This can't be "cubeified" as easily, so we have the user specify a list of ordinary variables to be its boundary. Thus, in practice below 'c must be a number of faces associated to a dimension, but the parser doesn't know the dimension, so it can't ensure that. The unnamed internal variable is included as the last one. *)
(* There's also a notation for record types that uses self variables like codata. *)
307
+
|SelfRecord : (Field.wrapped, 'acodatafield) Abwd.t -> 'a check
305
308
(* Empty match against the first one of the arguments belonging to an empty type. *)
306
309
|Refute : 'asynthlocatedlist* [ `Explicit|`Implicit ] -> 'a check
307
310
(* A hole must store the entire "state" from when it was entered, so that the user can later go back and fill it with a term that would have been valid in its original position. This includes the variables in lexical scope, which are available only during parsing, so we store them here at that point. During typechecking, when the actual metavariable is created, we save the lexical scope along with its other context and type data. A hole also stores its source location so that proofgeneral can create an overlay at that place, and the notation tightnesses of the hole location. *)
0 commit comments