From fcc0450a0608f3dcf1aceebebec0af5319450fb0 Mon Sep 17 00:00:00 2001 From: Alen Date: Sun, 19 Jan 2025 04:32:38 +0400 Subject: Update GHCI config --- dot_ghc/ghci.conf | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/dot_ghc/ghci.conf b/dot_ghc/ghci.conf index 064d660..c376198 100644 --- a/dot_ghc/ghci.conf +++ b/dot_ghc/ghci.conf @@ -1,5 +1,7 @@ +:set -package pretty-show -package hscolour + :set -XOverloadedStrings -:set -XOverloadedLists +-- :set -XOverloadedLists :set -XScopedTypeVariables :set -XPackageImports @@ -9,13 +11,38 @@ :set -ddump-deriv -- :set -fprint-explicit-foralls --- Colour -:set -package funnyprint -:set -interactive-print=FunnyPrint.funnyPrintC -:set prompt "\ESC[1;32mλ: \ESC[m" -:set prompt-cont "\ESC[1;32m : \ESC[m" - -- useful extensions by default :set -XTypeApplications -XKindSignatures +-- less repl noise +:set -Wno-type-defaults + import Prelude + +:{ +dotGHCI_myPrompt promptString ms _ = do + let main_module = head' [ m' | (m:m') <- ms, m == '*' ] + return $ concat [ "\ESC[33m\STX", main_module, "\ESC[0m\STX", promptString, " \ESC[0m\STX" ] + where + head' (x:_) = " \ESC[38;5;227m\STX" ++ x + head' _ = "" +:} +:set prompt-function dotGHCI_myPrompt "\ESC[32;1m\STXλ" +:set prompt-cont-function dotGHCI_myPrompt "\ESC[32;1m\STX:" + +-- Colourise ghci output (use :nopretty to disable) +-- Required libraries: pretty-show hscolour +import qualified Language.Haskell.HsColour as HSC +import qualified Language.Haskell.HsColour.Colourise as HSC +:{ +dotGHCI_myPrint :: (Show a) => a -> IO () +dotGHCI_myPrint a = putStrLn $ HSC.hscolour HSC.TTY myColourPrefs False False "" False $ Text.Show.Pretty.ppShow a + where + myColourPrefs = HSC.defaultColourPrefs +:} +:seti -interactive-print dotGHCI_myPrint +:def pretty \_ -> return ":set -interactive-print dotGHCI_myPrint" +:def nopretty \_ -> return ":set -interactive-print System.IO.print" +:pretty +:module -Language.Haskell.HsColour +:module -Language.Haskell.HsColour.Colourise -- cgit 1.4.1-2-gfad0