 
 (defn f-node
   [node log env]
-  (do (prn (str "checking ..." node)))
+  (do (prn (str "checking ..." node " in " env)))
   (let [type (my-type node)]
     (if (contains? actions type)
         ((actions type) node log env)
         (throw (new Exception (str "unrecognized node type -- " node))))))
 
 
-(def root-env (new-env #{} nil))
+(def root-env (new-env #{'z} {:depth 0}))
 
 (defn run-eg
   ([] (run-eg (second eg1)))

  ; todo: ... everything! ...
  log)

(defn f-let
  "recurs on: value of each binding, form"
  ; todo: unique symbols?
  ; todo: recur on binding values
  [node log env]
  (f-node (node :body)
          log
          (new-env (node :bindings) env)))

(defn f-app
  [node log env]
  (let [log2 (f-node (node :function) log env)]
    (loop [log-n log2 args (node :arguments)]
      (if (empty? args)
          log-n
          (recur (f-node (first args) log-n env) (rest args))))))

(def actions
 {"symbol"      f-symbol

(def eg1
  [(make-def 'id (make-fn '(x) 'x))
   (make-app 'f '[x y])
   (make-let '[[f g] [x z]] (make-app 'f '[x y]))
   (make-def '. (make-fn '(f g x) '(f (g x))))
   (make-def 'd (make-fn '(x) '(x x)))
   (make-def 't (make-fn '(f x) '(. f f x)))])
