Fork me on GitHub
#core-typed
<
2015-07-05
>
ppold05:07:23

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?

ambrosebs18:07:39

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

ambrosebs18:07:59

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

ambrosebs18:07:14

that should also work

ambrosebs18:07:32

the other problem is that zipmap is polymorphic too

ambrosebs18:07:42

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

ambrosebs18:07:08

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

ppold19:07:33

@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.

ppold19:07:14

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