   [v args]
   (let [fn-spec (get-spec v)]
     (when-let [arg-spec (:args fn-spec)]
-      (when (= ::invalid (conform arg-spec args))
+      (when (invalid? (conform arg-spec args))
         (let [ed (assoc (explain-data* arg-spec [:args]
                                        (if-let [name (spec-name arg-spec)] [name] []) [] args)
                    ::args args)]

  "Do not call this directly, use 'tuple'"
  ([forms preds] (tuple-impl forms preds nil))
  ([forms preds gfn]
     (reify
      Spec
      (conform* [_ x]
                (if-not (c/and (vector? x)
                               (= (count x) (count preds)))
                  ::invalid
                  (loop [ret x, i 0]
                    (if (= i (count x))
                      ret
                      (let [v (x i)
                            cv (dt (preds i) v (forms i))]
                        (if (= ::invalid cv)
                          ::invalid
                          (recur (if (identical? cv v) ret (assoc ret i cv))
                                 (inc i))))))))
      (unform* [_ x]
               (c/assert (c/and (vector? x)
                              (= (count x) (count preds))))
               (loop [ret x, i 0]
                 (if (= i (count x))
                   ret
                   (let [cv (x i)
                         v (unform (preds i) cv)]
                     (recur (if (identical? cv v) ret (assoc ret i v))
                            (inc i))))))
      (explain* [_ path via in x]
                (cond
                 (not (vector? x))
                 [{:path path :pred 'vector? :val x :via via :in in}]

                 (not= (count x) (count preds))
                 [{:path path :pred `(= (count ~'%) ~(count preds)) :val x :via via :in in}]

                 :else
                 (apply concat
                        (map (fn [i form pred]
                               (let [v (x i)]
                                 (when-not (valid? pred v)
                                   (explain-1 form pred (conj path i) via (conj in i) v))))
                             (range (count preds)) forms preds))))
      (gen* [_ overrides path rmap]
            (if gfn
              (gfn)
              (let [gen (fn [i p f]
                          (gensub p overrides (conj path i) rmap f))
                    gs (map gen (range (count preds)) preds forms)]
                (when (every? identity gs)
                  (apply gen/tuple gs)))))
      (with-gen* [_ gfn] (tuple-impl forms preds gfn))
      (describe* [_] `(tuple ~@forms)))))

(defn- tagged-ret [tag ret]
  (clojure.lang.MapEntry. tag ret))


(defn ^:skip-wiki map-spec-impl
  "Do not call this directly, use 'spec' with a map argument"
  [{:keys [req-un opt-un keys-pred pred-exprs opt-keys req-specs req req-keys opt-specs pred-forms opt gfn]
    :as argm}]
  (let [k->s (zipmap (concat req-keys opt-keys) (concat req-specs opt-specs))
        keys->specnames #(c/or (k->s %) %)
        id (java.util.UUID/randomUUID)]
    (reify
     Spec
     (conform* [_ m]
               (if (keys-pred m)
                 (let [reg (registry)]
                   (loop [ret m, [[k v] & ks :as keys] m]
                     (if keys
                       (let [sname (keys->specnames k)]
                         (if-let [s (get reg sname)]
                           (let [cv (conform s v)]
                             (if (invalid? cv)
                               ::invalid
                               (recur (if (identical? cv v) ret (assoc ret k cv))
                                      ks)))
                           (recur ret ks)))
                       ret)))
                 ::invalid))
     (unform* [_ m]
              (let [reg (registry)]
                (loop [ret m, [k & ks :as keys] (c/keys m)]
                  (if keys
                    (if (contains? reg (keys->specnames k))
                      (let [cv (get m k)
                            v (unform (keys->specnames k) cv)]
                        (recur (if (identical? cv v) ret (assoc ret k v))
                               ks))
                      (recur ret ks))
