Ah, ok. I guess I was thrown off because evaluating sequence and eduction results both produce output at the REPL, but only sequence can be output as JSON at the REPL.
On Friday, December 22, 2017 at 1:46:59 PM UTC-5, Sean Corfield wrote: > > Their respective docstrings give a hint here: > > > > Sequence – “returns a lazy sequence”. > > Eduction – “returns a reducible/iterable …”. > > > > (type (sequence identity [1 2 3])) => clojure.lang.LazySeq > > (type (eduction identity [1 2 3])) => clojure.core.Eduction > > > > If you look at that cheshire.generate/generate function -- > https://github.com/dakrone/cheshire/blob/master/src/cheshire/generate.clj#L116-L152 > > – you’ll see it is a large cond on the type of its argument and that it > supports clojure.lang.ISeq (which clojure.lang.LazySeq implements) but does > not support any of the types that clojure.core.Eduction has behind it. > > > > If you wrap your eduction call in a seq call, I expect it will work: > > > > (type (seq (eduction identity [1 2 3]))) => clojure.lang.LazySeq > > > > Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN > An Architect's View -- http://corfield.org/ > > "If you're not annoying somebody, you're not really alive." > -- Margaret Atwood > > > ------------------------------ > *From:* clo...@googlegroups.com <javascript:> <clo...@googlegroups.com > <javascript:>> on behalf of Jonathon McKitrick <jmcki...@gmail.com > <javascript:>> > *Sent:* Friday, December 22, 2017 6:32:54 AM > *To:* Clojure > *Subject:* Transducers eduction vs sequence > > I have a `get-summary` function that builds stats and returns them as a > web service. Under the hood, it calls quite a few map, group-by, filter, > etc. functions. > > I’m experimenting with transducers, and `sequence xform` does the trick > most of the time. But I want to understand `eduction` use cases. In most > cases, `eduction` seems to be a drop-in replacement. But in a few cases, > I’m seeing this error: > > JsonGenerationException Cannot JSON encode object of class: class > clojure.core.Eduction: clojure.core.Eduction@31accd87 > cheshire.generate/generate (generate.clj:152) > > So there’s something I’m missing about my understanding of `sequence` > versus `eduction`. Can someone shine some light on it? > > Thanks! > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clo...@googlegroups.com <javascript:> > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+u...@googlegroups.com <javascript:> > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+u...@googlegroups.com <javascript:>. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.