I don't think second's type is is smart enough. Try using nth or destructuring instead:
(let [[f s] v] (if (vector? s) (first s) s)) or (if (vector? (nth v 1)) (first (nth v 1)) s) Thanks, Ambrose On Thu, Apr 16, 2015 at 3:39 PM, Sven Richter <sver...@googlemail.com> wrote: > Hi, > > I have this code: > > (defalias html-label (t/HVec [Keyword (t/HMap :mandatory {:for String}) > String])) > (defalias html-form (t/HVec [Keyword (t/HMap :mandatory {:id String}) t/Any > *])) > (defalias html-form-group (t/HVec [html-label html-form])) > > (t/ann dt->hiccup [(HVec [Keyword (U Keyword (HVec [Keyword Number])) t/Any > t/Any *]) -> > html-form-group]) > (defmulti dt->hiccup (t/fn [col :- pt/et-column] > (if (vector? (second col)) > (first (second col)) > (second col)))) > > And here comes the error message when checking this function: > > Type Error (leiningen/td_to_hiccup.clj:25:34) Polymorphic function first > could not be applied to arguments: > Polymorphic Variables: > x > > Domains: > (t/HSequential [x t/Any *]) > (t/Option (t/EmptySeqable x)) > (t/NonEmptySeqable x) > (t/Option (clojure.lang.Seqable x)) > > Arguments: > (t/U Keyword (t/HVec [clojure.lang.Keyword java.lang.Number])) > > Ranges: > x :object {:path [(Nth 0)], :id 0} > nil > x > (t/Option x) > > in: (first (second col)) > in: (first (second col)) > > > ExceptionInfo Type Checker: Found 1 error clojure.core/ex-info (core.clj: > 4403) > > My assumption is that the check (if (vector? (second col will return only > true if it is this type: (HVec [Keyword Number]). However, I have the > impression that core.typed does not resolve the if expression properly. > Or maybe I am missing something completely. > > Any hints or recommendations? > > Thanks, > Sven > > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.