title: Alternative function for case match in haskell
body: <p>I am writing an API in Haskell which involves a DB query.
  Function will be something like do a db query and then return the response back.</p>
  <pre class="lang-hs prettyprint-override"><code>doAPICall :: Request -&gt; (Monad m Response)
  doAPICall req = do
      maybeValDB &lt;- getValFromDB (req.tokenId) -- Returns maybe type
      -- My current logic was to do a case match of maybe
      case maybeValDB of
          Just val -&gt; do
              --Some logic here using that val and return the response
              pure response
          Nothing -&gt; pure response
  </code></pre>
  <p>I am currently getting a maybe type from the DB query function. Is there a simple way like a one liner code to avoid this case match and send the response back.</p>
  <p>I thought of using <code>fromMaybe</code> but it should have same type for the default value. Here in this case if db returns Nothing I just want to exit the function with some response.</p>
  <p>In general in many cases the response which I get will be of maybe type and I have to do case matches the code looks very ugly and have repetitive patterns. Can anyone tell me better alternative for this instead of having case matches everywhere.</p>