Last active
August 29, 2015 14:05
-
-
Save krisajenkins/b9e4cf62512bd8d270a4 to your computer and use it in GitHub Desktop.
How to annotate?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ann lookup-by | |
(All [a b] | |
[b (IFn [a -> b]) (Option (Seq a)) -> (Option a)])) | |
(defn lookup-by | |
"Convenience filter. Returns the first item in coll where (= value (lookup-fn item))" | |
[value lookup-fn coll] | |
(first (filter (fn _ [x] | |
(= value (lookup-fn x))) | |
coll))) | |
; Example | |
(lookup-by "Kris" :name users) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Type Error (fynder.util:28:20) Function lookup-fn could not be applied to arguments: | |
Domains: | |
a | |
Arguments: | |
clojure.core.typed/Any | |
Ranges: | |
b | |
in: (lookup-fn x) | |
in: (cljs.core/= value (lookup-fn x)) | |
Type Error (fynder.util:27:3) Polymorphic function cljs.core/filter could not be applied to arguments: | |
Polymorphic Variables: | |
x | |
y | |
Domains: | |
(clojure.core.typed/IFn [x -> clojure.core.typed/Any :filters {:then (is y 0), :else tt}]) (cljs.core.typed/Option (cljs.core.typed/Seqable x)) | |
(clojure.core.typed/IFn [x -> clojure.core.typed/Any :filters {:then (! y 0), :else tt}]) (cljs.core.typed/Option (cljs.core.typed/Seqable x)) | |
(clojure.core.typed/IFn [x -> clojure.core.typed/Any]) (cljs.core.typed/Option (cljs.core.typed/Seqable x)) | |
Arguments: | |
(clojure.core.typed/IFn [clojure.core.typed/Any -> cljs.core.typed/Boolean]) (cljs.core.typed/Option (cljs.core.typed/Seq a)) | |
Ranges: | |
(cljs.core/ASeq y) | |
(cljs.core/ASeq (clojure.core.typed/I x (Not y))) | |
(cljs.core/ASeq x) | |
in: (cljs.core/filter (fn* _ ([x] (do (cljs.core/= value (lookup-fn x))))) coll) | |
in: (cljs.core/first (cljs.core/filter (fn* _ (# #)) coll)) | |
Type Checker: Found 2 errors | |
Found errors | |
Subprocess failed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment