Hi, The issue is that you can't use clojure.core/for in typed code.
You must use clojure.core.typed/for <http://clojure.github.io/core.typed/#clojure.core.typed/for>, and annotate the parameters and expected type. (ann map-span (All [x y y1] [(Map x y) [y -> y1] -> (Map x y1)])) (defn map-span [m f] (into {} (t/for [[k v] :- '[x y] m] :- '[x y1] [k (f v)]))) Here's a real gist <https://gist.github.com/frenchy64/176fa8aadfd5b0cbfc09>. Thanks, Ambrose On Wed, Oct 15, 2014 at 2:28 PM, kurofune <jesseluisd...@gmail.com> wrote: > Hi everyone, > > I am learning core.typed and ran into a stumbling block. When I use > annotations on normal functions and run 'check-ns', things work out ok, > > ;; works as expected >> (ann plus1 [Number -> Number]) >> (defn plus1 [n] (+ n 1)) >> >> ;; Works as expected >> (ann mult-arity [Number String -> (HMap :mandatory {:a Number :b >> String})]) >> (defn mult-arity [n s] {:a n :b s}) > > > > but with functions that use destructuring in their body, I run into > problems. > > > ;; Does not work. >> (ann map-span [Map Fn -> Map]) >> (defn map-span [m f] (into {} (for [[k v] m] [k (f v)]))) >> > > > clojure.lang.ExceptionInfo: Type Checker: Found 8 errors :: {:type-error > :top-level-error, :errors (#<ExceptionInfo clojure.lang.ExceptionInfo: > Polymorphic static method clojure.lang.RT/nth could not be applied to > arguments: Polymorphic Variables: x y Domains: (I (CountRange 1) (U (I > (clojure.lang.Seqable x) clojure.lang.Sequential) (Indexed x))) (Val 0) Any > (U nil (I (clojure.lang.Seqable x) clojure.lang.Sequential) (Indexed x)) > Int y Arguments: Any (Val 0) nil Ranges: x > (U x y) ... > > > ;; This also throws errors at the repl. >> (cf (fn [m f] (into {} (for [[k v] m] [k (f v)]))) [Map Fn -> Map]) > > > > > I have been on the core.typed wiki and googled around but to no avail. I > have also used lighter amounts of destructuring in the function parameters > and run into similar errors. I am having trouble even understanding the > error messages (even after reading the pertinent wiki page) so if someone > could give me some insights on how to do this properly, I would really > appreciate it. > > K > > -- > 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.