                    (fix merge-deps
                         locals->closed-overs)))
 
-          (println @locals->closed-overs)
-
           (let [;; rewrite the bindings to share closed-over information
                 bindings' (mapv (partial rewrite-closed-overs
-                                         locals->closed-overs)
+                                         @locals->closed-overs)
                                 bindings)
 
                 fns       (zipmap (map pattern/binding->symbol bindings')


                ;; compute the mapping from symbols to partial applications
                fns'      (map-vals fns
                                    (partial lift-fns defs-atom))]
            (println fns')

            (-> ast
                (assoc :bindings (->> bindings'
                                      (mapv (fn [binding]
                                              (ast/prewalk binding
                                                           (partial rewrite-locals
                                                                    fns'))))
                                      (mapv #(ast/prewalk %1
                                                          (partial rewrite-locals
                                                                   @locals->vars)))))
                
                ;; force to a let form
                (assoc :op :let))))



(defn rewrite-closed-overs
  [mapping binding]
  {:pre [(map? mapping)
         (pattern/binding? binding)]}
  (assert (pattern/binding? binding))
  (let [name         (pattern/binding->symbol binding)
        closed-overs (get mapping name)]
    (assoc-in binding [:init :closed-overs]
              (->> (for [[l le] (:locals (:env binding))
                         :when (contains? closed-overs
                                          (:name le))]
                     [l le])
                   (into {})))))


(defn lift-fns
