| 1 |
Class FieldType (F : Set) := mkFieldType { fldTy: F -> Set }. |
| 2 |
#[export] Hint Mode FieldType + : typeclass_instances. (* The F parameter is an input *) |
| 3 |
|
| 4 |
Inductive I1 := C. |
| 5 |
Inductive I2 := . |
| 6 |
|
| 7 |
#[export] Instance I1FieldType : FieldType I1 := { fldTy := I1_rect _ bool }. |
| 8 |
#[export] Instance I2FieldType : FieldType I2 := { fldTy := I2_rect _ }. |
| 9 |
|
| 10 |
Definition RecordOf F (FT: FieldType F) := forall f:F, fldTy f. |
| 11 |
|
| 12 |
Class MapOps (M K : Set) := { |
| 13 |
tgtTy: K -> Set; |
| 14 |
update: M -> forall k:K, tgtTy k -> M |
| 15 |
}. |
| 16 |
|
| 17 |
#[export] Instance RecordMapOps F (FT: FieldType F) : MapOps (RecordOf F FT) F := |
| 18 |
{ tgtTy := fldTy; update := fun r (f: F) (x: fldTy f) z => r z }. |
| 19 |
|
| 20 |
Axiom ex : RecordOf _ I1FieldType. |
| 21 |
|
| 22 |
Definition works := (fun ex' => update ex' C true) (update ex C false). |
| 23 |
Set Typeclasses Debug. |
| 24 |
Definition doesnt := update (update ex C false) C true. |