ghci: Add Hoogle commands

This commit is contained in:
Simon Bruder 2021-09-05 00:18:47 +02:00
parent aceeb7c35a
commit a94fd4d505
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC

View file

@ -4,8 +4,10 @@
home.file.".ghc/ghci.conf".text = /* haskell */ ''
:seti -XOverloadedStrings
-- Lambdabot (from https://wiki.haskell.org/GHC/GHCi#Lambdabot_Commands)
-- IDE-like features (from https://wiki.haskell.org/GHC/GHCi)
dotGHCI_escapeShellArg arg = "'" ++ concatMap (\c -> if c == '\''' then "'\\'''" else [c]) arg ++ "'"
-- Lambdabot
lb s1 s2 = return $ ":!lambdabot -n -e " ++ dotGHCI_escapeShellArg s1 ++ "\\ " ++ dotGHCI_escapeShellArg s2
:def! lb lb "" -- runs arbitrary lambdabot commands
:def! pl lb "pl" -- converts code to point-free (aka pointless) form
@ -16,6 +18,11 @@
:def! instances lb "instances" -- finds all instances of a given type class
:def! src lb "src" -- tries to find the source code for the given identifier
:def! oeis lb "oeis" -- looks up the On-Line Encyclopedia of Integer Sequences (https://oeis.org/)
-- Hoogle
:def! hoogle return . (":!hoogle -q --count=15 --color " ++) . dotGHCI_escapeShellArg
:def! search return . (":!hoogle -q --count=3 --color " ++) . dotGHCI_escapeShellArg
:def! doc return . (":!hoogle -q --color --info " ++) . dotGHCI_escapeShellArg
'';
home.file.".haskeline".text = ''
@ -27,6 +34,7 @@
home.packages = with pkgs; [
# GHC has a huge closure size, instead use nix-shell (ad-hoc or per-project)
#ghc
#haskellPackages.hoogle
#lambdabot
];
}