pp icon indicating copy to clipboard operation
pp copied to clipboard

Formatting of list returned from call to `clojure.core/into`

Open paintparty opened this issue 2 years ago • 6 comments

Hi Eero - Awesome library, thanks for making it! It has been a super useful and performant alternative to clojure.pprint/pprint.

I was working inside a project today and I noticed a small difference in the printing of a list that was returned from a call to clojure.core/into. As a sanity check, I reproduced the same thing in a clean sandbox project:

(ns sandbox-clj.core
  (:require 
   [me.flowthing.pp :as pp]
   [clojure.pprint]))

(clojure.pprint/pprint (into [] {:a 1 :b 2}))
;; => [[:a 1] [:b 2]]
(pp/pprint (into [] {:a 1 :b 2}))
;; => [:a 1, :b 2]

(clojure.pprint/pprint (into '() {:a 1 :b 2}))
;; => ([:b 2] [:a 1])
(pp/pprint (into '() {:a 1 :b 2}))
;; => (:b 2, :a 1)

(clojure.pprint/pprint (into #{} {:a 1 :b 2}))
;; => #{[:b 2] [:a 1]}
(pp/pprint (into #{} {:a 1 :b 2}))
;; => #{:b 2, :a 1}

P.S. I edited the example above from the original issue which was an example specific to clojure.spec.alpha/conform, where I first noticed it. Shortly after realized it was not specific to the output of conform when i saw it happening with into.

paintparty avatar Aug 29 '24 21:08 paintparty

Thanks for the report! I'll take a look when I get the chance.

eerohele avatar Aug 30 '24 02:08 eerohele

The bug is that pp prints map entries (clojure.lang.MapEntry) as if they were inside maps even when they're in other types of collections.

user=> (pprint [(clojure.lang.MapEntry. :a 1)])
[:a 1]

I'll fix that.

eerohele avatar Aug 30 '24 05:08 eerohele

This case turned out to be a bit trickier than I expected, but I think I have a fix now. Hope to have a new version out later this week.

eerohele avatar Sep 05 '24 06:09 eerohele

This should be fixed in 2024-09-09.69. If you get the chance, can you give it a try and let me know whether that fixes the issue for you?

eerohele avatar Sep 09 '24 12:09 eerohele

Works perfectly now. Thank you very much for the timely fix!

paintparty avatar Sep 09 '24 23:09 paintparty

Great, thanks for reporting back!

eerohele avatar Sep 10 '24 05:09 eerohele