UnifyTypeExpr unifies two type expressions. These are terms that contain ApplyFn nodes.
(xs []ast.BaseTerm, ys []ast.BaseTerm)
| 14 | // UnifyTypeExpr unifies two type expressions. These are terms that contain |
| 15 | // ApplyFn nodes. |
| 16 | func UnifyTypeExpr(xs []ast.BaseTerm, ys []ast.BaseTerm) (map[ast.Variable]ast.BaseTerm, error) { |
| 17 | if len(xs) != len(ys) { |
| 18 | return nil, fmt.Errorf("not of equal size") |
| 19 | } |
| 20 | u := unionFindFun{UnionFind{make(map[ast.BaseTerm]ast.BaseTerm)}, make(map[ast.Variable]ast.BaseTerm)} |
| 21 | if err := u.unifyFunctional(xs, ys); err != nil { |
| 22 | return nil, err |
| 23 | } |
| 24 | for t := range u.ufrel.parent { |
| 25 | v, ok := t.(ast.Variable) |
| 26 | if !ok { |
| 27 | continue |
| 28 | } |
| 29 | u.subst[v] = u.ufrel.find(v) |
| 30 | } |
| 31 | return u.subst, nil |
| 32 | } |
| 33 | |
| 34 | func (u *unionFindFun) unifyFunctional(xs []ast.BaseTerm, ys []ast.BaseTerm) error { |
| 35 | for i, x := range xs { |
no test coverage detected