title: Is there a better way to have optional function arguments in Haskell?
body: <p>I'm used to being able to define optional arguments like so in Python:</p>
  
  <pre><code>def product(a, b=2):
      return a * b
  </code></pre>
  
  <p>Haskell doesn't have default arguments, but I was able to get something similar by using a Maybe:</p>
  
  <pre><code>product a (Just b) = a * b
  product a Nothing = a * 2
  </code></pre>
  
  <p>This becomes cumbersome very quickly if you have more than multiple parameters though. For example, what if I want to do something like this:</p>
  
  <pre><code>def multiProduct (a, b=10, c=20, d=30):
      return a * b * c * d
  </code></pre>
  
  <p>I would have to have eight definitions of multiProduct to account for all cases.</p>
  
  <p>Instead, I decided to go with this:</p>
  
  <pre><code>multiProduct req1 opt1 opt2 opt3 = req1 * opt1' * opt2' * opt3'
      where opt1' = if isJust opt1 then (fromJust opt1) else 10
      where opt2' = if isJust opt2 then (fromJust opt2) else 20
      where opt3' = if isJust opt3 then (fromJust opt3) else 30
  </code></pre>
  
  <p>That looks very inelegant to me. Is there an idiomatic way to do this in Haskell that is cleaner?</p>