data Config = Config {
a :: Bool,
b :: Type1,
c :: Type2
}
pA :: Parser Bool
pB :: Parser Type1
pC :: Parser Type2
pConfig :: Parser Config
pConfig = Config <$> pA <*> pB <*> pC
opts :: ParserInfo Config
opts = info (pConfig <**> helper)
(fullDesc <> progDesc "My CLI" <> header "CLI executable")
main :: IO()
main = do
(Config a b c) <- execParser opts
-- Populate a default config using a b c values
Is it possible to parse a product type partially? Config is a product type with member a, b and c and assume this comes from a library, so I cannot redefine this. I only want to parse a and b without caring about c. But, since a "Parser Config" can only have a construction like below
Config <$> pA <*> pB <*> pC
due to being a product type, if I do not give a "pC" it errors out. How to correctly handle this scenario?