Skip to content

Instantly share code, notes, and snippets.

@pyrtsa
Last active August 2, 2018 15:43
Show Gist options
  • Save pyrtsa/5ec33f55d39016afc987 to your computer and use it in GitHub Desktop.
Save pyrtsa/5ec33f55d39016afc987 to your computer and use it in GitHub Desktop.
.ghci — Essential parts of my Haskell REPL config.
-- Show loaded modules in window title and use a green "λ>" as prompt.
-- Subsequent lines of multi-line commands shall begin with " |".
:set prompt "\SOH\ESC]0;GHCi: %s\BEL\ESC[32;1m\STXλ>\SOH\ESC[0m\STX "
:set prompt2 "\SOH\ESC[32;1m\STX |\SOH\ESC[0m\STX "
-- Paste and evaluate text from the OS X clipboard. (The pasted text also
-- prints in yellow unless pasting quietly using :paste-quiet.)
:set -package process
:def paste \_ -> do { paste <- System.Process.readProcess "pbpaste" [] ""; let cmd = if '\n' `elem` paste then ":{\ntype Ö = ()\n" ++ paste ++ "\n:}" else paste in putStrLn ("\SOH\ESC[33m\STX" ++ paste ++ "\SOH\ESC[0m\STX") >> return (":cmd return " ++ show cmd) }
:def paste-quiet \_ -> do { paste <- System.Process.readProcess "pbpaste" [] ""; let cmd = if '\n' `elem` paste then ":{\ntype Ö = ()\n" ++ paste ++ "\n:}" else paste in return (":cmd return " ++ show cmd) }
-- Hoogle (cabal install hoogle && hoogle data)
:def hoogle \str -> return $ ":! hoogle search --color --count=10 " ++ show str
:def hoogle-all \str -> return $ ":! hoogle search --color " ++ show str
:def doc \str -> return $ ":! hoogle search --color --info " ++ show str
-- Pointfree and Pointful (cabal install pointfree pointful)
:def pointfree \str -> return $ ":! pointfree " ++ show str
:def pf \str -> return $ ":! pointfree " ++ show str
:def pointful \str -> return $ ":! pointful " ++ show str
# Make Ctrl-V paste from clipboard in GHCi. (Under Bash, you actually
# need to hit Ctrl-V twice to first escape it. No big deal.)
bind: ctrl-v : p a s t e return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment