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
24 OK (gl, Set _) -> (state { prf = Just (newProof n (ctxt state) gl) }, "")
25 OK _ -> (state, "Goal is not a type")
26 err -> (state, show err)
27processCommand Quit state = (state { exitNow = True }, "Bye bye")
28processCommand (Eval t) state =
29 case check (ctxt state) [] t of
31 let nf = normalise (ctxt state) [] val in
33 err -> (state, show err)
34processCommand (Tac t) state
35 | Just ps <- prf state = case processTactic t ps of
38 then (state { prf = Just ps' }, resp)
39 else (state { prf = Nothing,
40 ctxt = addToCtxt (thname ps')
43 (context ps') }, resp)
44 err -> (state, show err)
45 | otherwise = (state, "No proof in progress")
47runShell :: ShellState -> IO ShellState
48runShell st = do (prompt, parser) <-
49 maybe (return ("> ", parseCommand))
51 return (show (thname st) ++ "> ", parseTactic))
55 Nothing -> return $ Right Quit
56 Just input -> do addHistory input
59 Left err -> do putStrLn (show err)
61 Right cmd -> do let (st', r) = processCommand cmd st
63 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