diff options
Diffstat (limited to 'src')
-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 |