1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE FlexibleContexts #-}
10import Control.Monad.Except (MonadError, MonadIO, liftIO, throwError)
11import qualified Data.List as List
12import System.Exit (ExitCode(ExitSuccess, ExitFailure))
13import System.Process (readProcessWithExitCode)
15import qualified AST.Pattern as Pattern
16import qualified Parse.Helpers as Parse
17import qualified Parse.Expression as Parse
18import qualified Reporting.Annotation as A
21{-| Forward function application `x |> f == f x`. This function is useful
22for avoiding parenthesis and writing code in a more natural way.
24(|>) :: a -> (a -> b) -> b
28{-| Backward function application `f <| x == f x`. This function is useful for
31(<|) :: (a -> b) -> a -> b
43 | CommandFailed String String
46{-| Run a command, throw an error if the command is not found or if something
49run :: (MonadError String m, MonadIO m) => String -> [String] -> m String
51 do result <- liftIO (unwrappedRun command args)
57 throwError (context (message err))
60 "failure when running:" ++ concatMap (' ':) (command:args) ++ "\n" ++ msg
64 CommandFailed stdout stderr ->
71unwrappedRun :: String -> [String] -> IO (Either CommandError String)
72unwrappedRun command args =
73 do (exitCode, stdout, stderr) <- readProcessWithExitCode command args ""
81 Left (missingExe command) -- UNIX
83 else if code == 9009 then
84 Left (missingExe command) -- Windows
87 Left (CommandFailed stdout stderr)
90missingExe :: String -> CommandError
93 "Could not find command `" ++ command ++ "`. Do you have it installed?\n\
94 \ Can it be run from anywhere? Is it on your PATH?"
100isDeclaration :: String -> Maybe String
101isDeclaration string =
102 case Parse.iParse (Parse.definition (,)) string of
103 Right (A.A _ (pattern, _)) ->
104 Just (List.intercalate "$" (Pattern.boundVarList pattern))
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