 
 ; Result :: {:product_name str
 ;            :listings [Listing]}
+
+
+; TODO
+; listing manufacturer "Eastman Kodak Company"
+
 
 (defn- parse-json
   "Parses a JSON string, keywordizing keys."

    (with-open [listings (io/reader (:listings-uri conf))
                out      (io/writer (:out-uri conf))]
      (doseq [result-item (->> (line-seq listings)
                               (mapv parse-json)
                               (t-match products))]
                               ;(iota/seq (:listings-uri conf))
                               ;(r/map (fn [s] (let [z (parse-json s)]
                               ;                 (println z)
                               ;                 z)))
                               ;(r-match products))]
                               ;(match-all products)
                               ;group-matches)]
        (json/generate-stream result-item out)

                  {:product_name (:product_name prod)
                   :listings (map listing matching-listings)}
                  matching-listings))))))

(p/defnp t-match [products listings]
  (let [manufacturer-matcher (make-manufacturer-matcher products manufacturer-matchers)
        title-matchers (map-vals make-title-matcher products)]
    (->> (t/map parse-json)
         (t/fold {:reducer (fn [m l]
                             (let [prod-name
                                   (->> l
                                        (match-listing manufacturer-matcher title-matchers)
                                        :product_name)]
                               (update m prod-name conj l)))
                  :reducer-identity (constantly {})
                  :combiner (fn [acc m]
                              (merge-with (partial apply conj) acc m))
                  :combiner-identity (constantly {})
                  :post-combiner (partial map (fn [[prod-name ls]]
                                                {:product_name prod-name
                                                 :listings ls}))})
         (t/tesser (t/chunk 1024 listings)))))

(defn -main
  [& args]
