title: Haskell: Parsing command line arguments
body: <p>This more of a style question, rather than a how to.</p>
  
  <p>So I've got a program that needs two command line arguments: a string and an integer.</p>
  
  <p>I implemented it this way:</p>
  
  <pre><code>main = do
    args@(~( aString : aInteger : [] ) ) &lt;- getArgs
    let parsed@( ~[(n,_)] ) = reads aInteger
    if length args /= 2 || L.null parsed
      then do
        name &lt;- getProgName
        hPutStrLn stderr $ "usage: " ++ name ++ " &lt;string&gt; &lt;integer&gt;"
        exitFailure
      else do
        doStuffWith aString n
  </code></pre>
  
  <p>While this works, this is the first time I've really used command line args in Haskell, so I'm not sure whether this is a horribly awkward and unreadable way to do what I want.</p>
  
  <p>Using lazy pattern matching works, but I could see how it could be frowned upon by other coders.  And the use of reads to see if I got a successful parse definitely felt awkward when writing it.</p>
  
  <p>Is there a more idiomatic way to do this?</p>