diff options
author | Marvin Borner | 2024-02-24 23:36:24 +0100 |
---|---|---|
committer | Marvin Borner | 2024-02-24 23:36:24 +0100 |
commit | 750eb72589a2da7712ded93e9a5060b2c30c24b5 (patch) | |
tree | e7bc83c26fbe5f601c147a37010e9ad7c41e11b4 /src/Helper.hs | |
parent | 9cf3e9fc04b8648b6bf21336e88f2a46de6f3f09 (diff) |
Added verbose mode
Mainly for CI right now, might extend in the future.
Diffstat (limited to 'src/Helper.hs')
-rw-r--r-- | src/Helper.hs | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/Helper.hs b/src/Helper.hs index fbb7dd8..a90ce94 100644 --- a/src/Helper.hs +++ b/src/Helper.hs @@ -45,7 +45,10 @@ printContext (Context inp path) = p $ lines inp errPrefix :: String errPrefix = "\ESC[101m\ESC[30mERROR\ESC[0m " -data Error = SyntaxError String | UndefinedIdentifier Identifier | UnmatchedMixfix [MixfixIdentifierKind] [Mixfix] | InvalidIndex Int | FailedTest Expression Expression Expression Expression | ContextualError Error Context | SuggestSolution Error String | ImportError String | OptimizerError String +okPrefix :: String +okPrefix = "\ESC[102m\ESC[30m OK \ESC[0m " + +data Error = SyntaxError String | UndefinedIdentifier Identifier | UnmatchedMixfix [MixfixIdentifierKind] [Mixfix] | InvalidIndex Int | FailedTest Expression Expression Expression Expression | PassedTest Expression Expression | ContextualError Error Context | SuggestSolution Error String | ImportError String | OptimizerError String instance Show Error where show (ContextualError err ctx) = show err <> "\n" <> printContext ctx @@ -62,6 +65,8 @@ instance Show Error where <> "\n\ESC[105m\ESC[30mnear\ESC[0m " <> unwords (map show ms) show (InvalidIndex err) = errPrefix <> "invalid index " <> show err + show (PassedTest exp1 exp2) = + okPrefix <> "test passed: " <> show exp1 <> " = " <> show exp2 show (FailedTest exp1 exp2 red1 red2) = errPrefix <> "test failed: " @@ -155,13 +160,20 @@ instance Show Expression where . showString " " . shows exp2 . showString "\ESC[33m)\ESC[0m" + showsPrec _ (MixfixChain [m]) = + showString "\ESC[33m\ESC[0m" . shows m . showString "\ESC[33m\ESC[0m" showsPrec _ (MixfixChain ms) = showString "\ESC[33m(\ESC[0m" . foldr1 (\x y -> x . showString " " . y) (map shows ms) . showString "\ESC[33m)\ESC[0m" - showsPrec _ (Prefix p e) = shows p . showString " " . shows e - showsPrec _ (Quote e ) = showString "\ESC[36m`\ESC[0m" . shows e - showsPrec _ (Unquote e ) = showString "\ESC[36m,\ESC[0m" . shows e + showsPrec _ (Prefix p e) = + showString "\ESC[33m(\ESC[0m" + . shows p + . showString " " + . shows e + . showString "\ESC[33m)\ESC[0m" + showsPrec _ (Quote e) = showString "\ESC[36m`\ESC[0m" . shows e + showsPrec _ (Unquote e) = showString "\ESC[36m,\ESC[0m" . shows e data Command = Input String | Watch String | Import String String | Test Expression Expression | ClearState | Time Expression | Length Expression | Blc Expression | Jot String deriving (Show) @@ -174,6 +186,7 @@ data ArgMode = ArgEval | ArgEvalBblc | ArgEvalBlc | ArgDumpBblc | ArgDumpBlc data Args = Args { _argMode :: ArgMode , _argNoTests :: Bool + , _argVerbose :: Bool , _argOptimizeTarget :: String , _argReducer :: String , _argPath :: Maybe String @@ -181,6 +194,7 @@ data Args = Args data EvalConf = EvalConf { _isRepl :: Bool + , _isVerbose :: Bool , _evalTests :: Bool , _nicePath :: String , _path :: String @@ -212,6 +226,7 @@ type EvalState = S.State Environment argsToConf :: Args -> EvalConf argsToConf args = EvalConf { _isRepl = isNothing $ _argPath args + , _isVerbose = _argVerbose args , _evalTests = not $ _argNoTests args , _path = path , _nicePath = path |