hy

Pretty print in Hy?


Is there something like pprint or clojure.pprint/pprint available in Hy? More specific, is there something that would convert something like this:

{:a {:a 0 :b 1 :c 2 :d 3 :e 4} :b {:a 0 :b 1 :c 2 :d 3 :e 4} :c {:a 0 :b 1 :c 2 :d 3 :e 4} :d {:a 0 :b 1 :c 2 :d 3 :e 4} :e {:a 0 :b 1 :c 2 :d 3 :e 4}}

In this (this is an example, doesn't need to be exactly like below):

{:e {:e 4 :d 3 :c 2 :b 1 :a 0}
 :d {:e 4 :d 3 :c 2 :b 1 :a 0}
 :c {:e 4 :d 3 :c 2 :b 1 :a 0}
 :b {:e 4 :d 3 :c 2 :b 1 :a 0}
 :a {:e 4 :d 3 :c 2 :b 1 :a 0}}

I already tried hy-repr and hydiomatic.utils/hypprint, however hy-repr didn't seem to pretty print long maps and hydiomatic does not work in recent versions of Hy.


Solution

  • Update

    Hyrule now provides pprint and related functions.

    Original answer

    No. Feel free to file an issue requesting it. However, our Emacs package, hy-mode, does have some auto-indent features (partly borrowed from Emacs's generic Lisp-editing code), and probably the Vim plugin does too, but that's been less actively maintained (to nobody's surprise, Lispers tend to prefer Emacs).