14.4 Identity Coercions

Identity coercions are special cases of coercions used to go around the uniform inheritance condition. Let C and D be two classes with respectively n and m parameters and f:(x1:T1)..(xk:Tk)(y:(C u1..un))(D v1..vm) a function which does not verify the uniform inheritance condition. To declare f as coercion, one has first to declare a subclass C' of C:

C' := [x1:T1]..[xk:Tk](C u1..un)

We then define an identity coercion between C' and C:
Id_C'_C := [x1:T1]..[xk:Tk][y:(Cx1..xk)]
    (y::(C u1..un))

We can now declare f as coercion from C' to D, since we can ``cast'' its type as (x1:T1)..(xk:Tk)(y:(Cx1..xk))(D v1..vm).
The identity coercions have a special status: to coerce an object t:(Ct1..tk) of C' towards C, we have not to insert explicitly Id_C'_C since (Id_C'_C t1..tk t) is convertible with t. However we ``rewrite'' the type of t to become an object of C; in this case, it becomes (C u1*..uk*) where each ui* is the result of the substitution in ui of the variables xj by tj.