This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-28
Channels
- # babashka (10)
- # beginners (140)
- # cider (6)
- # clj-kondo (10)
- # cljs-dev (39)
- # cljsrn (6)
- # clojars (1)
- # clojure (23)
- # clojure-europe (2)
- # clojure-spec (7)
- # clojure-uk (6)
- # clojurescript (1)
- # conjure (16)
- # cursive (3)
- # datomic (3)
- # emacs (6)
- # fulcro (13)
- # graalvm (3)
- # malli (8)
- # meander (4)
- # off-topic (43)
- # pathom (1)
- # pedestal (15)
- # re-frame (13)
- # reagent (3)
- # sci (25)
- # shadow-cljs (26)
- # sql (9)
- # testing (34)
- # tools-deps (80)
FYI: a deploy token is now required to deploy to Clojars. See https://groups.google.com/d/msg/clojure/UXx3ko0Ne-w/VnJA4eu6AQAJ for details. Thanks!
Generated a token and updated my repository auth config then deployed an artifact. Works great, thanks for making things more secure!
I've been using tokens for deploying several libs for a while now -- I was pleasantly surprised at how seamless the transition was!
I'm reading through clojure the essential reference and it claims that (range 10) is a reducible collection. That a reducible collection is anything that implements the coll-fold protocol. How do i check this? hmm maybe it has a mistake and its CollFold?
(satisfies? clojure.core.reducers/coll-fold (range 10))
;; 1. Unhandled java.lang.NullPointerException
;; (No message)
(satisfies? clojure.core.reducers/CollFold (range 10))
;; => true
CollFold
is for foldable things. CollReduce
is for reducible things https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/protocols.clj#L75
@drewverlee this is fresh in my mind because I just implemented CollFold
for plan
in next.jdbc
🙂
Thanks. so i don't misquote. the book claims:
> A "reducible" collection is a collection that provides reduce
with a custom implementation. If the collection implements the coll-fold
protocol, reduce
delegates the iteration to the collection itself instead of using the generic mechanism. For example, (range 10)
is a reducible (sequential) collection. r/map inc) (range 10
is also reducible collection although it does not exhibit other typical properties of a collection.
Generically, isn't reduce just a subtype of fold? Left fold? I guess the specific context is more important, what's the disquisition in clojure?
The specific protocol CollFold is part of the reducers library, and implements a kind of parallel reduce
It takes advantage of the internal tree like structure of many of clojures immutable collections (vectors and maps) to do a divide and conquer parallel reduce
It isn't used a ton because reducers are largely superceded by transducers, the parallel reduce operation being the one thing you don't get with the transducer additions
https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/reducers.clj#L48
The protocol is CollFold and coll-fold is the only protocol function that is part of that protocol
I see so CollReduce and CollFold overlaps with transdeucers in providing a seperation of concerns. But CollFold has parallelism and transdecuers are lazy?
Reducers are sort of an early iteration of the same idea as transducers: defining transformations of collections by transforming a function used to reduce the collection
Transducers do this in a very direct style without introducing wrapping of collections
As part of the work on reducers and transducers clojure grew some abstractions for collections that know how to reduce themselves
CollFold is more connected to those new specialized versions of reduce, then it is to the transformations of reducing functions
I see. That's similar to what the book is claiming to. Thanks for the clarification.