Skip to content
Browse files

Getting rid of macros that are no longer needed (feels goood...)

  • Loading branch information...
1 parent 60c4f03 commit 7ba4059ff49b153a6bd25aadc53fef19a632869c @roman committed Feb 17, 2012
Showing with 1 addition and 70 deletions.
  1. +1 −66 src/river/core.clj
  2. +0 −4 src/river/io.clj
View
67 src/river/core.clj
@@ -151,79 +151,14 @@
]
(produce-eof (reduce redux more))))
-(defn- ensure-in-list [producer-or-filter]
- (if (seq? producer-or-filter)
- producer-or-filter
- (list producer-or-filter)))
-
-(defn- nest-producer-filter-consumer
- ([consumers] consumers)
- ([producer-or-filter0 & more]
- (let [producer-or-filter (ensure-in-list producer-or-filter0)]
- ; when last item is a vector (multiple consumers),
- ; we just concat that to the producer/filter.
- ;
- ; This feature is being used currently zip* filter
- (if (and (nil? (next more))
- (vector? (first more)))
-
- (concat producer-or-filter
- (first more))
-
- (concat producer-or-filter
- `(~(apply nest-producer-filter-consumer more)))))))
-
-(defn gen-producer [& producer+filters-fn]
- "Composes a seq of partially applied producers/filters, and returns a
- new producer that receives either a producer, filter or consumer.
-
- Usage:
- > (def new-producer (gen-producer #(produce-seq (range 10 20) %)
- > #(produce-seq (range 1 10) %)
- > #(filter* even? %))"
- (fn composed-producer [consumer0]
- (reduce
- (fn [consumer producer+filter]
- (producer+filter consumer))
- consumer0
- (reverse producer+filters-fn))))
-
-
-(defmacro gen-producer> [& producers+filters]
- "Composes a seq of producers and filters, and returns a new
- producer that receives either a new producer, filter or consumer.
-
- Usage:
- > (def new-producer (gen-producer> (produce-seq (range 10 20))
- > (produce-seq (range 1 10))
- > (filter* even?)))"
- `(fn composed-producer [~'consumer]
- ~(apply nest-producer-filter-consumer
- (concat producers+filters `(~'consumer)))))
-
-(defmacro run>
- "Works the same way as river/run, its purpose is to ease the building
- of compositions between producers, filters and consumers by allowing
- to specify all of them without nesting one into the other.
-
- With river/run:
-
- > (river/run (producer2 (producer1 (filter1 (filter2 consumer)))))
-
- With river/run>:
-
- > (river/run> producer2 producer1 filter1 filter2 consumer)"
- [& more]
- `(run ~(apply nest-producer-filter-consumer more)))
-
(defmacro do-consumer [steps result]
"Binds the river-m monadic implementation to the domonad macro,
check clojure.algo.monads/domonad for further info."
`(monad/domonad river-m ~steps ~result))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
-;; Filters...
+;; Filters
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
View
4 src/river/io.clj
@@ -4,14 +4,10 @@
:author "Roman Gonzalez"
}
-;; Standard Lib ;;;;
-
(:require [clojure.java.io :as io])
(:import [java.io LineNumberReader
FileInputStream])
-;; Local Lib ;;;;;;;
-
(:use river.core)
(:use [river.seq :only
[produce-generate]]))

0 comments on commit 7ba4059

Please sign in to comment.
Something went wrong with that request. Please try again.