Last active
December 5, 2023 00:19
-
-
Save chshersh/9111d97578413323ba1b191299c54235 to your computer and use it in GitHub Desktop.
Config for GHCi with pretty output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- To run: | |
-- cabal repl -b pretty-simple | |
-- | |
-- Colorizing and pretty-printing ghci output | |
-- requires: pretty-simple | |
:set -interactive-print=Text.Pretty.Simple.pPrint | |
-- green bold lambdas and multiline mode | |
:set prompt "\ESC[1;32mλ: \ESC[m" | |
:set prompt-cont "\ESC[1;32mλ| \ESC[m" | |
-- useful flags | |
:set -fprint-explicit-foralls | |
:set +m | |
-- useful extensions by default | |
:set -XTypeApplications -XKindSignatures | |
-- useful default imports | |
import Data.Kind (Type, Constraint) | |
-- helpful macros | |
:def package \ m -> return $ ":! ghc-pkg --simple-output find-module " ++ m | |
:def no-pretty \_ -> return (":set -interactive-print=System.IO.print") | |
:def rr \_ -> return ":script ~/.ghc/ghci.conf" |
Here's my modification. It also works for stack, whatever you're under a stack project or not.
Thanks @chshersh
:def pretty \_ -> return (":set -interactive-print=Text.Pretty.Simple.pPrint")
:def no-pretty \_ -> return (":set -interactive-print System.IO.print")
:def package \m -> return $ ":! ghc-pkg --simple-output find-module " ++ m
:def rr \_ -> return ":script ~/.ghci"
:set prompt "\ESC[1;32mλ \ESC[m"
:set +m
:set +s
:set +t
:set -package pretty-simple
:set -fprint-explicit-foralls
:set -interactive-print=Text.Pretty.Simple.pPrint
:set -XTypeApplications -XKindSignatures
import Data.Kind (Type, Constraint)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found the problem. The
:load
will drop pre define things something likeghciColor
.pretty-simple
sounds like a good solution.