   #_(doall (concrete-parent 'Thinger:pred-key_1518831777))
   (doall (tc-kv :asdasd 3)))
 
-(defn tc-seq [ky val]
+(defn tc-seq [ky vl]
   (for [[_ _ [pt _ val-typ]] (schema-rules [:- 0])
         parent-type (concrete-parent pt)
-        child-types (tc-with-parent val-typ val)]
+        child-types (tc-with-parent val-typ vl)]
     (concat [parent-type ky] child-types)))
 
+(defn tc-empty-coll [exp]
+  (cond
+    (map? exp)
+    (for [[t _ col-typ] (schema-rules :=>)
+          :when (= col-typ :MAPP)]
+      [t exp])
+    (sequence-like? exp)
+    (for [[t _ col-typ] (schema-rules :=>)
+          :when (= col-typ :SEQQ)]
+      [t exp])))
+
+;; TODO empty case?
 (defn tc-complex [exp]
   (cond
+    (and (coll? exp) (empty? exp)) (tc-empty-coll exp)
     (map? exp) ;; TODO pred-current type
     (mapcat (fn [[k v]] (tc-kv k v)) (seq exp))
     (sequence-like? exp)


(declare tc-with-parent)

(defn tc-kv [ky val]
  (if-let [res (not-empty
                (doall
                 (concat
                  (for [[_ _ [pt _ val-typ]] (schema-rules [:- ky])
                        parent-type (concrete-parent pt)
                        child-types (tc-with-parent val-typ val)]
                    (concat [parent-type ky] child-types))
                  ;; keys that are mispelled locals
                  (for [[k _ [pt _ val-typ]] (schema-rules :-)
                        :when (and (not= k ky)
                                   (similar-key 0 k ky))
                        parent-type (concrete-parent pt)
                        child-types (tc-with-parent val-typ val)]
                    (concat [parent-type [:subst ky k]] child-types))
                  ;; keys that have complex children that match
                  ;; this value

#_(pp)
;; printing

(defn gen-path [path value]
  (if (empty? path)
    value
    (let [[x & xs] path]
      (cond
        (and (integer? x) (zero? x))
        [(gen-path xs value)]
        :else {x (gen-path xs value)}))))

(defn print-path [[x & xs] leaf-node edn]
   (if (and x (get edn x))
     (let [v (get edn x)]
       [:group
        (str (if (map? edn)
               (str (pr-str x) " ")
               "")
             (if (and (not (map? v)) (integer? (first xs)))
               "["
               "{"))
        (if (map? v)
          [:nest 2
           :line
           (print-path xs leaf-node v)]
          (print-path xs leaf-node v))
        (if (and (not (map? v)) (integer? (first xs)))
          "]"
          "}")])
     leaf-node))

#_(pprint-document (print-path2 [:cljsbuild :builds 0 :css-dirs] [:group "hey"] {:cljsbuild {:builds [{:css-dirs []}]}})
                 {:width 20})

(defn blank-document? [x]
  (or (nil? x)
      (and (string? x) (string/blank? x))
      (empty? x)))

(defn print-document [d]
  (if (blank-document? d)
    [:group :break :break]
    [:group :break d :line]))

(defn print-path-error
  ([{:keys [path orig-config] :as error} leaf-node document]
   (prn document)
   (prn (print-document document))
   [:group
    (color "\n------- Figwheel Configuration Error -------\n" :red)
    :break
    (error-help-message error)
    :break
