cdepillabout/pretty-simple

document how to use pretty-simple as default ghci printer

nasosev opened this issue · 4 comments

I have pretty-simple set as the default printer for my project by putting the following in my .ghci file at the root of the project:

:set -ignore-package pretty-simple -package pretty-simple
:def! pretty \ _ -> pure ":set -interactive-print Text.Pretty.Simple.pPrint"
:pretty

How can I also enable the compact output option for the default printer?

Thanks a lot.

Yeah, I'd like to flesh out that section of documentation a little. I started looking in to it properly once, but the whole process of writing .ghci files is fraught with awkward edge cases. Especially when needing to import packages. For one thing, I've never been clear about the rules around qualifying imports. I eventually got hung up on haskell/cabal#7789. There are definitely upstream improvements to be made, in GHC as well as Cabal.

Anyway, this works for me on GHC 9.2:

import Text.Pretty.Simple
ghciInteractivePrint = pPrintOpt CheckColorTty defaultOutputOptionsDarkBg{outputOptionsCompact = True}
:set -interactive-print ghciInteractivePrint

Thank you. That works for me if I input it within the ghci repl, but it does not work automatically when I put it in my .ghci file (my project is using LTS 19.2 for ghc-9.0.2).

I tried the above comment's solution and set up ~/.ghci to this:

import Text.Pretty.Simple

ghciInteractivePrint = pPrintOpt CheckColorTty defaultOutputOptionsDarkBg{outputOptionsCompact = True}
:set -interactive-print ghciInteractivePrint

image

however it doesn't seem to work and I have to manually type them to work. could anyone help me figure out what's the problem?

Yeah, I've ended up often using cabal repl -b pretty-simple --repl-options="-interactive-print Text.Pretty.Simple.pPrintForceColor" because the .ghci solution doesn't always work (see haskell/cabal#7789).