core-typed

Typed Clojure, an optional type system for Clojure
ppold 2015-07-05T05:18:23.000263Z

Hi, I have been having issues with polymorphic functions when using partial. I finally got it to pass but I don’t know what 3rd, 4th and 5th parameters are for.

(t/ann zipmap-test [(t/Vec t/Kw) -> (t/Map t/Kw t/Str)])
(defn zipmap-test [column-names]
  (let [partialt (t/inst partial (t/Map t/Kw t/Str) (t/Vec t/Kw) t/Any t/Any
                         t/Any (t/Vec t/Str))]
    ((partialt zipmap column-names) ["a" "b" "c" "d"])))
Apart from that, is there a better way to describe the types in this case?

2015-07-05T18:52:39.000264Z

ppold: it might be easier to use ann-form to give partialt a more specific type

2015-07-05T18:52:59.000265Z

ie (ann-form partial [[ -> ...] ....-> ....])

2015-07-05T18:53:14.000266Z

that should also work

2015-07-05T18:53:32.000267Z

the other problem is that zipmap is polymorphic too

2015-07-05T18:53:42.000268Z

so you can do the same to zipmap, use ann-form or inst

2015-07-05T18:54:08.000269Z

(partial (inst zipmap Kw Str) column-names) might work

ppold 2015-07-05T19:06:33.000270Z

@ambrosebs using inst in zipmap actually worked! I tried that first but I actually sent (t/Vec t/Kw) (t/Vec (t/Str) as arguments, and though that the problem must be in partial.

ppold 2015-07-05T19:07:14.000271Z

I still have issues understanding the error messages but I am still liking core.typed a lot!