nixos-config/users/simon/modules/ghci.nix
Simon Bruder 10b8d432d5
Relicense
This applies the REUSE specification to the repository, so the licensing
information can be tracked for every file individually.
2024-01-13 14:39:22 +01:00

45 lines
1.8 KiB
Nix

# SPDX-FileCopyrightText: 2021 Simon Bruder <simon@sbruder.de>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
{ pkgs, ... }:
{
home.file.".ghc/ghci.conf".text = /* haskell */ ''
:seti -XOverloadedStrings
-- 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
:def! unpl lb "unpl" -- converts back from point-free (aka pointless) form
:def! do lb "do" -- converts binds to do notation
:def! undo lb "undo" -- converts do blocks to bind notation
:def! index lb "index" -- finds the module that defines the given identifier
: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 = ''
completionType: MenuCompletion
maxHistorySize: Just 10000
historyDuplicates: IgnoreAll
'';
home.packages = with pkgs; [
# GHC has a huge closure size, instead use nix-shell (ad-hoc or per-project)
#ghc
#haskellPackages.hoogle
#lambdabot
];
}