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.

Reply via email to