-
Notifications
You must be signed in to change notification settings - Fork 3
/
.ghci
41 lines (34 loc) · 1 KB
/
.ghci
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
:set +m
:set -package ghc
:module + System.Directory
:module + System.Environment
:module + System.IO
:module + Control.Monad
:module + Data.List
let llM :: IO String
llM = do
e <- System.Environment.getEnvironment
case lookup "GHCI_LOAD" e of
Nothing -> return ""
Just f -> do
putStrLn $ "LOADING " ++ f
return $ ":load " ++ f
let sourceGHCI :: String -> IO String
sourceGHCI f = do
b <- doesFileExist f
when b $ putStrLn $ "SOURCING " ++ f
if b
then readFile f
else return ""
let commands :: [IO String] -> IO String
commands = liftM (intercalate "\n") . sequence
:def init (const $ commands [sourceGHCI ".extensions.ghci", sourceGHCI ".ghc_options.ghci"])
:def ll (const $ commands [llM, sourceGHCI ".reload.ghci"])
:def rl (const $ commands [return ":re", sourceGHCI ".reload.ghci"])
:init
:ll
:module - System.Directory
:module - System.Environment
:module - System.IO
:module - Control.Monad
:module - Data.List