I would like to use pmap within a transducer, if I write my code using regular map, it works fine. However if I use pmap I get an arity exception. Is it possible to achieve this in clojure or am I doing something wrong? If it were to be impossible, could someone point to the documentation on why that happens? just out of curiosity. Pasted below is my code and the beginning of the arity exception.
(def get-in-map (comp
(pmap read-csv)
))
clojure.lang.Compiler$CompilerException: clojure.lang.ArityException: Wrong number of args (1) passed to: core/pmap, compiling:
pmap doesn't support creating a transducer with it. If you think about it, it makes sense. The parallelisation you get from pmap vs map breaks the guarantees of a transducer. It complects a parallel context with the description of the process. As described here transducers separate out the consuming context from the code that describes the task to be accomplished.
The core implementation of a parallel context for transducers is as yet unimplemented: see this ticket. However, you could use core.async/pipeline or core.reducers/fold to create one yourself.