Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document how to use pretty-simple as default ghci printer #108

Open
nasosev opened this issue Apr 8, 2022 · 4 comments
Open

document how to use pretty-simple as default ghci printer #108

nasosev opened this issue Apr 8, 2022 · 4 comments

Comments

@nasosev
Copy link

nasosev commented Apr 8, 2022

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.

@georgefst
Copy link
Collaborator

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

@nasosev
Copy link
Author

nasosev commented Apr 8, 2022

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).

@cdepillabout cdepillabout changed the title Use options with pretty-simple as default ghci printer document how to use pretty-simple as default ghci printer Jun 8, 2022
@scarf005
Copy link

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?

@georgefst
Copy link
Collaborator

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants