From 0a770acbf5560dfa88d80d49cdb202941ff92fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 21 Nov 2026 10:55:28 +0100 Subject: Report error on unexpected tool specification in config file --- src/Config.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Config.hs b/src/Config.hs index e243609..caf9cda 100644 --- a/src/Config.hs +++ b/src/Config.hs @@ -36,11 +36,7 @@ data ConfigTool instance FromYAML (FilePath -> Config) where parseYAML = withMap "Config" $ \m -> do - configTool <- foldr1 (<|>) - [ Just . ToolPath . T.unpack <$> m .: "tool" -- tool path as string - , Just <$> m .: "tool" - , return Nothing - ] + configTool <- m .:? "tool" configTests <- (map (compile . T.unpack) <$> foldr1 (<|>) [ fmap (:[]) (m .: "tests") -- single pattern , m .:? "tests" .!= [] -- list of patterns @@ -66,9 +62,13 @@ instance FromYAML Number where node -> typeMismatch "int or float" node instance FromYAML ConfigTool where - parseYAML = withMap "tool specification" $ \m -> foldr1 (<|>) - [ ToolPath . T.unpack <$> m .: "path" - , ToolCabal <$> m .: "cabal" + parseYAML n = foldr1 (<|>) $ map ($ n) + [ withMap "tool specification" $ \m -> foldr1 (<|>) + [ ToolPath . T.unpack <$> m .: "path" + , ToolCabal <$> m .: "cabal" + ] + , withStr "tool path" $ return . ToolPath . T.unpack + , typeMismatch "tool specification" ] findConfig :: Bool -> IO (Maybe FilePath) -- cgit v1.2.3