The :- is just a bit of syntax to signify an annotation. As a rule, it goes *after* the form you might expect to attach metadata to.
eg. (t/fn [a :- Int] :- Num ....) is [Int -> Num] (t/let [a :- Int, 1] ...) checks 1 as being under Int. (t/let [[a b] :- '[Num Num], [1 2]] ...) checks [1 2] as under '[Num Num], then assigns whatever expression is to the left the type '[Num Num] (t/for [[a b] :- '[Num Num], foo] :- Ret e) assigns the left hand side of the binder type '[Num Num], where the right hand side is (U nil (Seqable '[Num Num])). This is because every iteration [a b] is an element of foo. The return type Ret is similarly for one iteration, and the inferred type will be (Seq Ret). Thanks, Ambrose On Wed, Oct 15, 2014 at 6:34 PM, kurofune <jesseluisd...@gmail.com> wrote: > Thanks Ambrose, > > It makes way better sense after looking at your gist. I still don't > *quite* understand the :- syntax, though. Is it just introducing a type > declaration to the data structure that comes after it? > > This is a super cool project, by the way. > > K > > > On Wednesday, October 15, 2014 3:14:58 PM UTC-5, Ambrose Bonnaire-Sergeant > wrote: >> >> Hi, >> >> The issue is that you can't use clojure.core/for in typed code. >> >> You must use clojure.core.typed/for >> <http://www.google.com/url?q=http%3A%2F%2Fclojure.github.io%2Fcore.typed%2F%23clojure.core.typed%2Ffor&sa=D&sntz=1&usg=AFQjCNHQ7AqglYarx-OVAqx1sUXcO4c9vw>, >> 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 <jessel...@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 clo...@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+u...@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+u...@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. > -- 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.