Skip to content

Instantly share code, notes, and snippets.

@atroche
Created January 21, 2015 05:01
Show Gist options
  • Save atroche/3ba3545183d8e256b76b to your computer and use it in GitHub Desktop.
Save atroche/3ba3545183d8e256b76b to your computer and use it in GitHub Desktop.
(ann tuples-to-map [(Vec Any) -> (Map Any Any)])
(defn tuples-to-map [tuples]
(into {} tuples))
@atroche
Copy link
Author

atroche commented Jan 21, 2015

Type Error (hat_tip/core.clj:49:3) Polymorphic function into could not be applied to arguments:
Polymorphic Variables:
    x
    y

Domains:
    (Map x y) (U (Seqable (U (Seqable (clojure.lang.IMapEntry x y)) (IMapEntry x y) nil (t/HVec [x y]))) nil)
    (Vec x) (U (Seqable x) nil)
    (t/Set x) (U (Seqable x) nil)
    (t/Coll Any) (U (Seqable Any) nil)

Arguments:
    (HMap :complete? true) (IPersistentVector Any)

Ranges:
    (Map x y)
    (Vec x)
    (t/Set x)
    (t/Coll Any)

with expected type:
    (Map Any Any)

in: (into {} tuples)
in: (into {} tuples)

@atroche
Copy link
Author

atroche commented Jan 21, 2015

this works:

(ann tuples-to-map [(Seqable Any) -> (Coll Any)])
(defn tuples-to-map [tuples]
  (into {} tuples))

@frenchy64
Copy link

You probably want (All [k v] [(Seqable '[k v]) -> (Map k v)])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment