14.6 Declaration of Coercions
14.6.1 Coercion qualid : class1 >-> class2.
Declares the construction denoted by qualid as a coercion between
class1 and class2.
Error messages:
-
qualid not declared
- qualid is already a coercion
- FUNCLASS cannot be a source class
- SORTCLASS cannot be a source class
- Does not correspond to a coercion
qualid is not a function.
- Cannot find the source class
- qualid does not respect the inheritance uniform condition
- The target class does not correspond to class2
When the coercion qualid is added to the inheritance graph, non
valid coercion paths are ignored; they are signaled by a warning.
Warning :
-
Ambiguous paths: |
[f11;..;fn11] : C1>->D1 |
|
... |
|
[f1m;..;fnmm] : Cm>->Dm
|
Variants:
-
Coercion Local qualid : class1 >-> class2.
Declares the construction denoted by qualid as a coercion local to
the current section.
- Coercion ident := term
This defines ident just like Definition ident :=
term, and then declares ident as a coercion between it
source and its target.
- Coercion ident := term : type
This defines ident just like
Definition ident : type := term, and then
declares ident as a coercion between it source and its target.
- Coercion Local ident := term
This defines ident just like Local ident :=
term, and then declares ident as a coercion between it
source and its target.
14.6.2 Identity Coercion ident:class1 >-> class2.
We check that class1 is a constant with a value of the form
[x1:T1]..[xn:Tn](class2 t1..tm) where m is the
number of parameters of class2. Then we define an identity
function with the type
(x1:T1)..(xn:Tn)(y:(class1 x1..xn))
(class2 t1..tm), and we declare it as an identity
coercion between class1 and class2.
Error messages:
-
Clash with previous constant ident
- class1 must be a transparent constant
Variants:
-
Identity Coercion Local ident:ident1 >-> ident2.
Idem but locally to the current section.