title: Pattern Matching a Haskell list of variable size
body: <p><strong>EDIT</strong>: I shouldn't be coding when this tired. I was compiling a different copy of the program than I was running. Sorry for wasting your time.</p>
  
  <p>I have the following code to make a single argument optional in my program's startup.</p>
  
  <pre><code>main = do
      args &lt;- getArgs
      handleArgs args
  
  handleArgs :: [String] -&gt; IO ()
  handleArgs (server:nick:channel:[]) = IRC.startIRC server 6667 nick channel
  handleArgs (server:port:nick:channel:[]) = IRC.startIRC server (read port :: Int) nick    channel
  handleArgs _ = putStrLn "Incorrect arguments given."
  </code></pre>
  
  <p>If I run it like <code>./program irc.freenode.net 6667 somenick #somechannel</code>, it runs. However, if I run it like <code>./program irc.freenode.net somenick #somechannel</code>, which should make args be a list <code>"irc.freenode.net":"somenick":"#somechannel":[]</code> if I understand it correctly, 
  it gives a pattern match error pointing to the <code>args &lt;- getArgs</code> line when I try to run it after compiling with ghc.</p>
  
  <p>More precisely, the error is:
  <code>mbot: user error (Pattern match failure in do expression at core.hs:9:4-32)</code></p>