 (ns latte-compiler.static-analysis
   (:require [clojure.core.match :as match]
             [clojure.algo.monads :as m]
-            [latte-compiler.util :as util]))
+            [latte-compiler.util :as util]
+            ))
 
 (defrecord ClassDef [extends fields funs])
 (defrecord FunDef [name outType inTypes])

                     )
               ]
              res)
      :eadd (match/match (third expr)
              [:minus]
              (m/domonad util/phase-m
                [[vars1 lexpr] (annotate-expr glob-state vars (second expr))
                 [vars2 rexpr] (annotate-expr glob-state vars1 (fourth expr))
                 res (if (and
                           (= (get-type lexpr) [:int])
                           (= (get-type rexpr) [:int]))
                       (util/succ [vars2 (with-type [:eadd lexpr [:minus] rexpr] [:int])])
                       (util/err (str "expr invalid; expected int,int, found " (print-type (get-type lexpr)) ", " (print-type (get-type rexpr)) " in: " location))
                       )
                 ]
                res)
              [:plus]
              (m/domonad util/phase-m
                [[vars1 lexpr] (annotate-expr glob-state vars (second expr))
                 [vars2 rexpr] (annotate-expr glob-state vars1 (fourth expr))
                 res (if
                       (and
                         (= (get-type lexpr) [:int])
                         (= (get-type rexpr) [:int]))
                       (util/succ [vars2 (with-type [:eadd lexpr [:plus] rexpr] [:int])])
                       (if
                         (and
                           (= (get-type lexpr) [:string])
                           (= (get-type rexpr) [:string]))
                         (util/succ [vars2 (with-type [:eapp [:ident "_concatStrings"] [lexpr rexpr]] [:string])])
                         (util/err (str "expr invalid; expected int,int or string,string, found " (print-type (get-type lexpr)) ", " (print-type (get-type rexpr)) " in: " location)))
                       )
                 ]
                res)
              )
      :eapp (m/domonad util/phase-m
              [ident (m-result (second expr))
               [nvar args] (reduce (fn [buff tmp] (m/domonad util/phase-m [[tmvar tmargs] buff [ntmvar nexpr] (annotate-expr glob-state tmvar tmp)] [ntmvar (conj tmargs nexpr)])) (m-result [vars []]) (rest (rest expr)))

              [[vars1 lexpr] (annotate-expr glob-state vars (second expr))
               [vars2 rexpr] (annotate-expr glob-state vars1 (fourth expr))
               op (m-result (third expr))
               res (annotate-erel vars2 lexpr rexpr op location)
               ]
              res)
      :emul (m/domonad util/phase-m
