From ea38fdd4614bc8d3c5adf36932b0e5808a4cba67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Wed, 22 Mar 2023 21:47:42 +0100 Subject: Fix non-exhaustive pattern match warnings --- src/GDB.hs | 2 +- src/Parser.hs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/GDB.hs b/src/GDB.hs index 8c23bb9..e73a049 100644 --- a/src/GDB.hs +++ b/src/GDB.hs @@ -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 _ = "" 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 -- cgit v1.2.3