This repository has been archived by the owner on Jul 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.hs
42 lines (32 loc) · 1.54 KB
/
Main.hs
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
42
module Main where
import Commands(commands)
import GHCEval(Session, initializeGHC, eval)
import System.Console.Shell.Backend.Readline(readlineBackend)
import System.Console.Shell(ShellDescription(shellCommands, maxHistoryEntries,
historyFile, historyEnabled, evaluateFunc, commandStyle),
CommandStyle(CharPrefixCommands), initialShellDescription, runShell)
{- 1. Create a list of shell commands and an evaluation function
2. Create a shell description (using mkShellDescription)
3. Set up the initial shell state
4. Run the shell (using runShell)
runShell :: ShellDescription st -> ShellBackend bst -> st -> IO st -}
main :: IO ()
main = do s <- initializeGHC
runShell (createShellDescription) (readlineBackend) s
return ()
-- | Default shell configuration.
createShellDescription :: ShellDescription Session
createShellDescription =
initialShellDescription {
-- set the available commands, see also the function 'commands'
shellCommands = commands,
-- commands are prefixed with a colon character
commandStyle = CharPrefixCommands '!',
-- set the function called when something else than a command was entered
evaluateFunc = eval,
-- command history is turned on
historyEnabled = True,
-- the maximum number of commands remembered in one session
maxHistoryEntries = 1024,
-- there is no file storing the commands of previous sessions
historyFile = Just "/home/gwern/.shellac" }