About a year ago I released the
pretty-simple Haskell library.
pretty-simple gives an easy way to pretty-print Haskell datatypes. It is easier to use and has more features than other pretty-printing libraries.
One drawback of
pretty-simple is that if you forget to use it, you're basically out of luck. You need to go back and re-print the datatype using functions provided by
pretty-simple. This is quite annoying.
To get around this, I created a small command line program that will pretty-print anything on stdin. I explain how it works below.
Imagine you have the following datatypes:
You then create some values using these datatypes like the following:
If you run this in GHCi and
print bar, you get something like the following:
This is hard to read.
pretty-simple can be used to make this easier to read:
Command Line Interface to
I just released version 22.214.171.124 of
pretty-simple. This adds an optional executable that can be used to pretty-print anything passed in on stdin.
It can be installed like the following:
This will install an executable called
~/.local/bin/. Make sure that
~/.local/bin/ is on your
PATH before you try to run it. Note that the executable will not get installed if you don't use the
When run on the command line, it takes all stdin and tries to pretty-print it. That means that after running it and pasting in what you want to format, you need to hit Ctrl-D. Here is an example of running it:
This is great for when you accidentally use
pPrint. Just copy and paste to get nicely formatted output.
pretty-simple is nice to visualize complex Haskell datatypes. Adding a CLI executable makes it even easier to pretty-print things in a pinch.