Skip to content

Instantly share code, notes, and snippets.

@chshersh
Last active December 5, 2023 00:19
Show Gist options
  • Save chshersh/9111d97578413323ba1b191299c54235 to your computer and use it in GitHub Desktop.
Save chshersh/9111d97578413323ba1b191299c54235 to your computer and use it in GitHub Desktop.
Config for GHCi with pretty output
-- 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"
@AurevoirXavier
Copy link

AurevoirXavier commented Jul 23, 2020

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