 
 (defn add-arg
   [vmap arg]
-  (match/match arg [_ type ident]
-    (add-var vmap ident type)
+  (match/match arg [:arg type ident]
+    (m/domonad util/phase-m
+      [[num vmap2] (add-arg-var vmap ident type)]
+      [[:arg type [:ident num]] vmap2]
+      )
     )
   )
 
 (defn add-args
   [vmap args]
-  (loop
-    [vmap vmap
-     args (rest args)]
-    (if (empty? args)
-      vmap
-      (recur (add-arg vmap (first args)) (rest args))))
+  (reduce (fn [buf arg]
+            (m/domonad util/phase-m
+              [[tmprgs vmap2] buf
+               [narg vmap3] (add-arg vmap2 arg)] [(conj tmprgs narg) vmap3]))
+    [:succ [[:args] vmap]] (rest args))
   )
 
 (defn terminated

              )
      :eapp (m/domonad util/phase-m
              [ident (m-result (second expr))
               args (reduce merge-checks (m-result []) (map #(annotate-expr glob-state vars %) (rest (rest expr))))
               actargtypes (m-result (vec (map get-type args)))
               fundef (m-result (second (find (.-funs glob-state) ident)))
               expargtypes (m-result (.-inTypes fundef))
               outtype (m-result (.-outType fundef))
               res (if (= expargtypes actargtypes)
                     (util/succ (with-type [:eapp ident args] outtype))
                     (do (println ident) (println expargtypes) (println args) (println actargtypes) (util/err (str "somthieng in " location)))
                     )
               ]

  (m/domonad util/phase-m
    [exp-type exp-type
     actual-type (do (println actual-type) actual-type)
     res (if (= actual-type exp-type)
           (util/succ res)
           (util/err (str "return type invalid; expected " (print-type exp-type) ", found " (print-type actual-type) " in " location)))
     ]
    res)

