;;;; A diamond, with a type crossing it. ;;;; ;;;; The tree is pkg-diamond -> {area, draw} -> shape, which is the case that ;;;; only works if a package may import a package and if the shared bottom is ;;;; loaded once. The proof is not that it compiles but that a shape/Box built ;;;; inside area/ is accepted by a function declared inside draw/: two copies ;;;; of one struct would be two types, and passing one to the other would fail ;;;; to unify with a message naming shape/Box twice and explaining nothing. ;;;; ;;;; shape is never imported here directly. It arrives only through the two ;;;; middles, so its names are in scope because a package's import qualified ;;;; them, not because this file did — which is the inner-alias rule, visible. (import area "pkgs/area") (import draw "pkgs/draw") (defn main [] i32 (let [b (area/unit)] ;; Built in area/, measured in draw/ — one type or no program. (print (draw/describe b)) (println "") (print (area/of b)) (println "") ;; And the bottom package's own constructor, reached through the chain. (print (area/of (shape/box 4 5))) (println "")) 0)