1{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
11import Control.Monad.State
12import System.Console.Readline
14data ShellState = State { ctxt :: Context,
15 prf :: Maybe ProofState,
19initState c = State c Nothing False
21processCommand :: Command -> ShellState -> (ShellState, String)
22processCommand (Theorem n ty) state
23 = case check (ctxt state) [] ty of
25 case isSet (ctxt state) [] t of
26 OK _ -> (state { prf = Just (newProof n (ctxt state) gl) }, "")
27 _ -> (state, "Goal is not a type")
28 err -> (state, show err)
29processCommand Quit state = (state { exitNow = True }, "Bye bye")
30processCommand (Eval t) state =
31 case check (ctxt state) [] t of
33 let nf = normalise (ctxt state) [] val
34 tnf = normalise (ctxt state) [] ty in
35 (state, show nf ++ " : " ++ show ty)
36 err -> (state, show err)
37processCommand (Print n) state =
38 case lookupDef n (ctxt state) of
39 Just tm -> (state, show tm)
40 Nothing -> (state, "No such name")
41processCommand (Tac e) state
42 | Just ps <- prf state = case runElab e ps of
45 then (state { prf = Just ps' }, resp)
46 else (state { prf = Nothing,
47 ctxt = addToCtxt (thname ps')
50 (context ps') }, resp)
51 err -> (state, show err)
52 | otherwise = (state, "No proof in progress")
54runShell :: ShellState -> IO ShellState
55runShell st = do (prompt, parser) <-
56 maybe (return ("> ", parseCommand))
58 return (show (thname st) ++ "> ", parseTactic))
62 Nothing -> return $ Right Quit
63 Just input -> do addHistory input
66 Left err -> do putStrLn (show err)
68 Right cmd -> do let (st', r) = processCommand cmd st
70 if (not (exitNow st')) then runShell st'
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list