Closed Malabarba closed 5 years ago
Presumably this is because Datomic entities do not implement IPersistentMap and therefore map?
returns false.
What does (-> entity class supers) give you?
The class is datomic.query.EntityMap
. The supers returns:
#{datomic.query.EMapImpl java.lang.Object clojure.lang.IPersistentCollection clojure.lang.Seqable clojure.lang.ILookup clojure.lang.IType datomic.Entity clojure.lang.Associative}
I believe datomic.query.EntityMap
extends print-method
. Is it possible that's not getting used?
Fipp's built in Edn printer intentionally does not respect print-method for two reasons:
To elaborate on the second point: As of the introduction of tagged literals, Fipp output promises to be valid Edn. That is, no #< ... >
forms are emitted. Anything that might be unreadable will instead be emitted as a tagged literal with a quoted pr-str value.
There's a few possible solutions here to accommodate Datomic:
-edn
which converts a type in to a standard Clojure type for later printing. Note: I reserve the right to change that protocol! It's unlikely, but possible.Do any of these work for you?
Option 2 sounds like the easiest of those 3, but there's also option 4:
4: Since fipp does this by design and doesn't consider it a bug then we close both issues as not-a-bug. :-)
That's what I would do, but maybe @bbatsov or @cichli have a different opinion.
Option 4 would mean dropping support for fipp from CIDER. This is fine by me, but others might disagree. I simply don't want to deal with users complaining about behaviours they deem unexpected.
Option 4 would mean dropping support for fipp from CIDER.
Or just not making it the default value of cider-pprint-fn
.
I don't think it's the default even now (we changed it when people started complaining). But there's no point in supporting it, if we know some people will run into such issues. Pretty sure @cichli wasn't aware of those problems when he elected to add it to cider and make it the default.
It's possible to endow Fipp with a "best effort" pretty printing mode, where it falls back to print-method where appropriate. However, you'll probably get the followup complaint: "How come Datomic entities are not pretty printed?" Thoughts on that?
And on the topic of extending a protocol: I could entertain making that an official public protocol, but I don't want to be in the business of extending that protocol to all the popular custom types out there. I doubt you want to be in that business either. However, entertaining the thought for a minute: What other types have people complained about?
I don't recall anything besides the Datomic complaints.
I'm going to close this, since the current behavior is expected and -edn
is pretty stable, so safe to override if you want to add specific improvements for datomic in your project. Thanks for the report.
See https://github.com/clojure-emacs/cider/issues/1505. At least one example are datomic entities one gets by doing something like
Normally they would print like this:
With fipp they are printed like this: