diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2026-11-21 10:55:28 +0100 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2026-11-23 19:55:55 +0100 |
| commit | 0a770acbf5560dfa88d80d49cdb202941ff92fdc (patch) | |
| tree | c1f0bfebc56b39496bd563089c41f1541fd92826 | |
| parent | 5f79ebf2615bc974ff118b6dfc7e3c22f284d2ae (diff) | |
Report error on unexpected tool specification in config file
| -rw-r--r-- | src/Config.hs | 16 |
1 files 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) |