| 1 |
% [Typeclass, Coq Instances, Elpi Instances] |
| 2 |
% the instances of the given typeclass should be in the same order as Coq |
| 3 |
func correct_instance_order_aux gref, (list tc-instance), (list gref). |
| 4 |
:name "tc-correct-instance-order-aux" |
| 5 |
correct_instance_order_aux _ [] []. |
| 6 |
correct_instance_order_aux TC [tc-instance I1 _ | TL1] [I1 | TL2] :- |
| 7 |
correct_instance_order_aux TC TL1 TL2. |
| 8 |
|
| 9 |
% [Typeclasses of Coq, Elpi Instances] |
| 10 |
func correct_instance_order (list gref), (list prop). |
| 11 |
:name "tc-correct-instance-order" |
| 12 |
correct_instance_order [] _. |
| 13 |
correct_instance_order [TC | TL] ElpiInst :- |
| 14 |
coq.TC.db-for TC CoqInst, |
| 15 |
std.map-filter ElpiInst (x\r\ sigma I\ x = tc.instance _ I TC _, r = I) ElpiInstTC, |
| 16 |
if (correct_instance_order_aux TC CoqInst ElpiInstTC) |
| 17 |
(correct_instance_order TL ElpiInst) |
| 18 |
(coq.error "Error in import order\n" |
| 19 |
"Expected :" CoqInst "\nFound :" ElpiInstTC). |
| 20 |
|
| 21 |
:name "tc-same-order-main" |
| 22 |
main _ :- |
| 23 |
std.findall (tc.instance _ _ _ _) ElpiInst, |
| 24 |
correct_instance_order {coq.TC.db-tc} ElpiInst. |