            (list?? x))
        (empty? (rest x))))
 
+
+(defn complex-value? [v]
+  (or (list?? v) (map?? v) (fn? v) (-> v meta :ref)))
+
+(def simple-value? (complement complex-value?))
+
 (defn prep-key [k]
   (if (fn? k)
     (keyword (str "pred-key_" (hash k)))
     k))
 
-(defn handle-key-type [orig-key predicate-key-name node t]
-  (if (fn? orig-key)
-    [[predicate-key-name :?- [node :> t]]
-     [predicate-key-name :k= orig-key]]
-    [[orig-key :- [node :> t]]]))
-
 (defn decompose [type-gen-fn node' s']
-  (letfn [(decomp [node s]
+  (letfn [(handle-key-type [orig-key predicate-key-name node t]
+            (if (fn? orig-key)
+              [[predicate-key-name :?- [node :> t]]
+               [predicate-key-name := orig-key]]
+              [[orig-key :- [node :> t]]]))
+          (decomp [node s]
             (if (nil? s)
               nil
               (let [[[k' v] & r] s


(defn find-keyword-predicate [parent-type]
  (when-let [[pred-id _ [pt _ kt]] (first (*schema-rules* [:parent :?- parent-type]))]
    (when-let [pred-func (last (first (*schema-rules* [:k= pred-id])))]
      [pred-func kt])))

;; this is what implements or

  (let [{:keys [ky] :as p} (docs-for parent-type k)]
    (if ky
      [:group
       "-- Docs for key " (color (pr-str k) :bold) " --" 
       :break
       (color ky
                       :underline)
       :break]
      "")))

