title: Parsing CLI options for a product type
body: <p>I want to parse command line options corresponding to a product type resembling below.</p>
  
  <pre class="lang-hs prettyprint-override"><code>
  data SumType1 = d | e | f
  
  data SumType2 = g | h | i
  
  data Config = Config {
      a :: Bool,
      b :: SumType1,
      c :: SumType2
  }
  
  pB :: Parser SumType1
  pB = flag' d &lt;|&gt; flag' e &lt;|&gt; flag' f
  
  pC :: Parser SumType2
  pC = flag' g &lt;|&gt; flag' h &lt;|&gt; flag' i
  
  pConfig :: Parser Config
  pConfig = Config &lt;$&gt; pA &lt;*&gt; pB &lt;*&gt; pC
  
  opts :: ParserInfo Config
  opts = info (pConfig &lt;**&gt; helper)
         (fullDesc &lt;&gt; progDesc "My CLI" &lt;&gt; header "CLI executable")
  
  main :: IO()
  main = do
         (Config a b c) &lt;- execParser opts
  -- Populate a default config using a b c values
  </code></pre>
  
  <p>For simplicity I did not add "long" and "help" here with flag'.</p>
  
  <p>The above is what I have right now. It may also be that "d" itself is another sum type. In this the problem is each of the a, b, c values I need to specify on the command line.</p>
  
  <p>How do I specify such that either of a, b or c may not be specified and the CLI parser still works. Currently if I do not pass even one of a, b or c the parser fails with an error message. I understand that my builder construction is incorrect, but, I am not able to grasp how to fix it. Hope I have described the problem correctly, if not please let me know.</p>