diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2023-03-22 21:47:42 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2023-03-22 21:47:42 +0100 |
commit | ea38fdd4614bc8d3c5adf36932b0e5808a4cba67 (patch) | |
tree | f78f34bce6539d7ad97d09c03babed0b9be3b8cd | |
parent | 1bff4ce6c10c762f846709578d6f036b3e45691f (diff) |
Fix non-exhaustive pattern match warnings
-rw-r--r-- | src/GDB.hs | 2 | ||||
-rw-r--r-- | src/Parser.hs | 14 |
2 files changed, 11 insertions, 5 deletions
@@ -190,7 +190,7 @@ gdbCompletion gdb (revcmd, _) = do gdbCommandRes gdb ("-complete " <> T.pack (show (reverse revcmd))) >>= \case (Done, resp) | Just (MiList matches) <- lookup "matches" resp -> do - return ("", map (\(MiString m) -> Completion (T.unpack m) (T.unpack m) False) matches) + return ("", concatMap (\case MiString m -> [Completion (T.unpack m) (T.unpack m) False]; _ -> []) matches) _ -> return ("", []) diff --git a/src/Parser.hs b/src/Parser.hs index dd0716d..b79931b 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -492,14 +492,16 @@ instance Functor CommandDef where fmap f (CommandDef types ctor) = CommandDef types (f . ctor) instance Applicative CommandDef where - pure x = CommandDef [] (\[] -> x) + pure x = CommandDef [] (\case [] -> x; _ -> error "command arguments mismatch") CommandDef types1 ctor1 <*> CommandDef types2 ctor2 = CommandDef (types1 ++ types2) $ \params -> let (params1, params2) = splitAt (length types1) params in ctor1 params1 $ ctor2 params2 param :: forall a. ParamType a => String -> CommandDef a -param name = CommandDef [(name, SomeParam (Proxy @a) Proxy)] (\[SomeParam Proxy (Identity x)] -> fromJust $ cast x) +param name = CommandDef [(name, SomeParam (Proxy @a) Proxy)] $ \case + [SomeParam Proxy (Identity x)] -> fromJust $ cast x + _ -> error "command arguments mismatch" data ParamOrContext a @@ -513,7 +515,9 @@ instance ParamType a => ParamType (ParamOrContext a) where | otherwise -> fail $ showParamType @a Proxy <> " not available from context type '" <> T.unpack (textExprType ctx) <> "'" paramOrContext :: forall a. ParamType a => String -> CommandDef a -paramOrContext name = CommandDef [(name, SomeParam (Proxy @(ParamOrContext a)) Proxy)] (\[SomeParam Proxy (Identity x)] -> fromJust $ cast x) +paramOrContext name = CommandDef [(name, SomeParam (Proxy @(ParamOrContext a)) Proxy)] $ \case + [SomeParam Proxy (Identity x)] -> fromJust $ cast x + _ -> error "command arguments mismatch" cmdLine :: CommandDef SourceLine cmdLine = param "" @@ -530,7 +534,9 @@ instance ParamType TestStep where showParamType _ = "<code line>" innerBlock :: CommandDef [TestStep] -innerBlock = CommandDef [("", SomeParam (Proxy @InnerBlock) Proxy)] (\[SomeParam Proxy (Identity x)] -> fromJust $ cast x) +innerBlock = CommandDef [("", SomeParam (Proxy @InnerBlock) Proxy)] $ \case + [SomeParam Proxy (Identity x)] -> fromJust $ cast x + _ -> error "command arguments mismatch" command :: String -> CommandDef TestStep -> TestParser [TestStep] command name (CommandDef types ctor) = do |