(push) (datatype Math (Num i64)) (sort MathVec (Vec Math)) (let v1 (vec-of (Num 1) (Num 2))) (let v2 (vec-of (Num 2) (Num 2))) (union (Num 1) (Num 2)) (check (= v1 v2)) (function MyVec (MathVec) Math) (MyVec v1) (check (MyVec v2)) (check (= (MyVec v1) (MyVec v2))) (let v3 (vec-of (Num 4) (Num 5))) (union (Num 4) (Num 6)) (union (Num 5) (Num 7)) ;; We don't have any (MyVec v3) yet (fail (check (= (MyVec v3) (MyVec (vec-of (Num 6) (Num 7)))))) (MyVec v3) (check (= (MyVec v3) (MyVec (vec-of (Num 6) (Num 7))))) (pop) (push) (datatype Math (Num i64)) (sort MathVec (Vec Math)) (let v1 (vec-of (Num 1) (Num 2))) (let v2 (vec-of (Num 2) (Num 2))) (union (Num 1) (Num 2)) (function MyVec (MathVec) Math) ;; make a reference to v1 (MyVec v1) (extract (MyVec v1)) ;; rebuilding creates (MyVec v2) (check (= (MyVec v1) (MyVec v2))) (pop) (push) (datatype Math (Add i64 i64) (Expensive :cost 100)) (sort MathVec (Vec Math)) (let myvec (vec-of (Expensive))) (let cheapvec (vec-of (Add 1 2))) (function VecContainer (MathVec) Math) (let myvecontainer (VecContainer cheapvec)) (union myvecontainer (Expensive)) ;; (vec-push (vec-empty) (VecContainer (vec-push (vec-empty) (Add 1 2)))) ;; should have cost 4 (extract myvec 0) (pop)