   (let [new-ast (atom {:modules modules})]
 
     (doseq [m modules]
-      (doseq [[sym ast] (get whole-program-ast m)]
+      (debug "Pondering module:" m)
+
+      (assert (:forms (get whole-program-ast m)))
+
+      (doseq [ast (:forms (get whole-program-ast m))]
+        (debug "Pondering line:" (util/line ast) (:op ast))
+
         (if (pattern/def? ast)
           (if (contains? reach-set (:var ast))
-            (swap! new-ast assoc-in [m sym] ast)
+            (swap! new-ast update-in [m :forms] conj ast)
+
             (info "Discarding unused def form,"
                   (util/line ast)))
-          (warn "Discarding non-def top level form,"
-                (util/line ast)))))
+
+          (do (warn "Discarding non-def top level form,"
+                    (util/line ast))
+              (print (:form ast)))))
+
+      (swap! new-ast update-in [m :forms] vec))
 
     @new-ast))
 



(defn -step-reach-set
  [ast]
  (util/map-vals
   (fn [v]
     (->> v
          (map (partial get ast))
          (reduce set/union v)))))


(defn global-reach-set
  "λ {Symbol → #{Symbol}} → {Symbol → #{Symbol}}

  Computes the reach set for an entire program"
  [whole-program-ast]
  (util/fix -step-reach-set
            (-> whole-program-ast
                (util/map-vals reach-set))))


(defn trim-with-emit-set

    which is the entry point of the prorgam. It is with respect to this
    function that all other defs will be considered for elimination."
  [{:keys [modules] :as ast} {:keys [entry] :as options}]
  (let [;; Compute the {Var → #{Var}} form of the whole program
        symbol-sets (->>  (for [m     modules
                                form  (:forms (get ast m))
                                :when (pattern/def? form)]
                            [(:var form) (reach-set form)])
                          (into {})
                          global-reach-set)

        ;; The emit set is now trivially
        emit-set (get symbol-sets (resolve entry))]
    (info emit-set)
    (trim-with-emit-set ast emit-set)))
