From 341108ed29e6c9ee7de636d588b1fc55ad85ffc9 Mon Sep 17 00:00:00 2001 From: Pat Shields Date: Mon, 24 Mar 2014 21:28:31 -0400 Subject: [PATCH] Fix typing errors. --- project.clj | 2 +- src/graf_znak/accumulators.clj | 9 ++++----- src/graf_znak/annotations.clj | 11 +++++++++++ src/graf_znak/core.clj | 12 ++---------- 4 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 src/graf_znak/annotations.clj diff --git a/project.clj b/project.clj index c46832a..b68cb54 100644 --- a/project.clj +++ b/project.clj @@ -4,7 +4,7 @@ :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.5.1"] - [org.clojure/core.typed "0.2.39"]] + [org.clojure/core.typed "0.2.40"]] :core.typed {:check [graf-znak.accumulators graf-znak.hooks graf-znak.atom-storage diff --git a/src/graf_znak/accumulators.clj b/src/graf_znak/accumulators.clj index 53e157e..ca0c5a8 100644 --- a/src/graf_znak/accumulators.clj +++ b/src/graf_znak/accumulators.clj @@ -1,6 +1,7 @@ (ns graf-znak.accumulators "Contains the accumulator record and types as well as pre-built instances." - (:require [clojure.core.typed :refer :all]) + (:require [clojure.core.typed :refer :all] + [graf-znak.annotations :refer :all]) (:import [java.util.concurrent.atomic AtomicLong])) ;; Accumulator @@ -65,9 +66,7 @@ [state :- Any input :- input-type] (let [vals (map #(get input %) fields)] - ;; As of this writing pred requires fully qualified symbols if check-ns - ;; is called from another namespace. blech. - (assert ((pred (clojure.core.typed/Set (clojure.core.typed/Coll Any))) state)) + (assert ((pred (Set (Coll Any))) state)) (if (not-any? nil? vals) - (conj state (apply hash-map (interleave fields vals))) + (conj state (zipmap fields vals)) state))))) diff --git a/src/graf_znak/annotations.clj b/src/graf_znak/annotations.clj new file mode 100644 index 0000000..1deb241 --- /dev/null +++ b/src/graf_znak/annotations.clj @@ -0,0 +1,11 @@ +(ns graf-znak.annotations + "Contains extra annotations of non graf-znak functions." + (:require [clojure.core.typed :refer :all])) + +(ann ^:no-check clojure.core/not-any? (Fn [(Fn [Any -> Boolean]) (Seq Any) + -> Boolean])) +(ann ^:no-check clojure.core.reducers/map + (All [x y] + (Fn [(Fn [x -> Any]) (Seq x) -> (Seq Any)]))) +(ann ^:no-check clojure.core.reducers/filter + (Fn [(Fn [Any -> Boolean]) (Seq Any) -> (Seq Any)])) diff --git a/src/graf_znak/core.clj b/src/graf_znak/core.clj index 3a88d25..82d3f36 100644 --- a/src/graf_znak/core.clj +++ b/src/graf_znak/core.clj @@ -2,22 +2,14 @@ (:require [clojure.core.typed :refer :all] [clojure.core.reducers :as r] [graf-znak.hooks :refer :all] - [graf-znak.accumulators :refer :all])) + [graf-znak.accumulators :refer :all] + [graf-znak.annotations :refer :all])) ;; Type aliases (def-alias hooks-type (Seq hook-type)) (def-alias state-type (Map hook-type HookStorage)) -;; Annotations -(ann ^:no-check clojure.core/not-any? (Fn [(Fn [Any -> Boolean]) (Seq Any) - -> Boolean])) -(ann ^:no-check clojure.core.reducers/map - (All [x y] - (Fn [(Fn [x -> Any]) (Seq x) -> (Seq Any)]))) -(ann ^:no-check clojure.core.reducers/filter - (Fn [(Fn [Any -> Boolean]) (Seq Any) -> (Seq Any)])) - (defn> process-hook "Processes a single input for all accumulators in a hook." :- Any