;;;; A data type imported from a package, which was a refusal until vendor/edn ;;;; needed one — "an imported data type is not implemented yet (milestone 4)". ;;;; ;;;; Four things, and each is a different way the rename could be half done: ;;;; the type named in a signature, a constructor written on this side of the ;;;; import, a constructor the *package* wrote and the import had to rewrite, ;;;; and a match whose patterns name the cases bare. The last is the one that ;;;; needs no rename at all — a pattern resolves against the scrutinee's type — ;;;; and it is here so that the day someone qualifies case names too, this says ;;;; what broke. (import tree "pkgs/tree") (defvar frame Allocator) ;; The type in a signature, and a bare pattern over a value the package made. (defn describe [t tree/Node] string (match t (Leaf _n) "leaf" (Branch _k) "branch" Empty "empty")) (defn main [] i32 (set frame (arena-new 4096)) (with-allocator frame (let [kids (vec-new tree/Node)] ;; Written here, qualified, which is how the importer spells it. (push kids (tree/Node.Leaf {.n (i64 1)})) ;; Written inside the package, unqualified, and rewritten by the import. (push kids (tree/leaf (i64 2))) (push kids (tree/nothing)) (let [t (tree/Node.Branch {.kids kids})] (println (describe t)) (println (describe (tree/leaf (i64 9)))) (println (describe (tree/nothing))) ;; Summed by the package's own match, over a value this file built, so ;; the two sides agree about the layout and not only about the names. (println (tree/total t))))) (free-all frame) (arena-destroy frame) 0)