Revision b878abe5 src/dimension.ml
src/dimension.ml | ||
---|---|---|
340 | 340 |
| Dident id1, Dident id2 when id1 = id2 -> () |
341 | 341 |
| _ -> raise (Unify (dim1, dim2)) |
342 | 342 |
|
343 |
|
|
343 |
let rec semi_unify dim1 dim2 = |
|
344 |
let dim1 = repr dim1 in |
|
345 |
let dim2 = repr dim2 in |
|
346 |
if dim1.dim_id = dim2.dim_id then () else |
|
347 |
match dim1.dim_desc, dim2.dim_desc with |
|
348 |
| Dunivar, _ |
|
349 |
| _ , Dunivar -> assert false |
|
350 |
| Dvar , Dvar -> |
|
351 |
if dim1.dim_id < dim2.dim_id |
|
352 |
then dim2.dim_desc <- Dlink dim1 |
|
353 |
else dim1.dim_desc <- Dlink dim2 |
|
354 |
| Dvar , _ -> raise (Unify (dim1, dim2)) |
|
355 |
| _ , Dvar when not (occurs dim2 dim1) -> |
|
356 |
dim2.dim_desc <- Dlink dim1 |
|
357 |
| Dite(i1, t1, e1), Dite(i2, t2, e2) -> |
|
358 |
begin |
|
359 |
semi_unify i1 i2; |
|
360 |
semi_unify t1 t2; |
|
361 |
semi_unify e1 e2 |
|
362 |
end |
|
363 |
| Dappl(f1, args1), Dappl(f2, args2) when f1 = f2 && List.length args1 = List.length args2 -> |
|
364 |
List.iter2 semi_unify args1 args2 |
|
365 |
| Dbool b1, Dbool b2 when b1 = b2 -> () |
|
366 |
| Dint i1 , Dint i2 when i1 = i2 -> () |
|
367 |
| Dident id1, Dident id2 when id1 = id2 -> () |
|
368 |
| _ -> raise (Unify (dim1, dim2)) |
|
344 | 369 |
|
Also available in: Unified diff