Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by

eduction expects its source collection to be Iterable (link: 1), and its print-method goes through print-sequential (link: 2). This implies a promise that may restrict the use-case of an eduction over a virtual collection, e.g. a pure IReduceInit source that may be backed by I/O or some other resource. I have found it useful to construct these I/O reducibles and wrap them with an eduction. But when interacting at the REPL, printing out an eduction-wrapped IReduceInit will fail. Does the print-method impl for eduction require too much? This is a only minor inconvenience more than anything else, obviously I could create my own flavor of eduction.

Totally hypothetical example:

`
(defn database-index
[name]
(reify clojure.lang.IReduceInit

(reduce [_ f init]
  (with-open [rdr (fressian/create-reader (io/input-stream name))]
   (loop [] ...reduce impl...)))))

(eduction (filter (as-of #inst "2012-01-01")) (database-index "eavt.fress"))
;; ^ throws when printed by repl
`

(link: 1) https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L7336-L7338
(link: 2) https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L7360

Proposed Approach:
Since we have #object tagged literals, let eduction print like an opaque #object

1 Answer

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1747 (reported by gshayban)
...