title: Can record's field be matched with some value and assigned to a parameter at the same time?
body: <p>After a relatively brief text on Haskell wiki about pattern matching of records, I'm not sure if record's field can be matched with some value and assigned to a  parameter at the same time.</p>
  
  <pre><code>-- Sample record type
  data Rec = Rec { uid :: Int, name :: String }
  
  -- Function to update Rec's fields
  updateRec :: Rec -&gt; Rec
  
  -- basic matching with record data constructor
  updateRec (Rec _ []) = Rec 0 "Nobody"
  
  -- dtto with as-pattern at 2nd param
  updateRec (Rec idn ns@"Alice") = Rec (idn+1) (ns ++ "+1")
  
  -- basic matching by fields values
  updateRec Rec {name = "Bob", uid = 42} = Rec (10^6) "SuperBob"
  
  -- Q: how to match by name field and assign it's value ?
  updateRec Rec {name = "Bob", uid = idn} =
      Rec {uid = (idn+1), name = ("Bob" ++ "+1")}
  
  -- Q: as-pattern works only on the whole record, not on a field
  updateRec rec@(Rec {name = "Bob", uid = idn}) =
      Rec {uid = (idn+1), name = (name rec ++ "+1")}
  
  -- Q: pattern guards do work, but they are a bit clumsy
  updateRec Rec {name = uname, uid = idn}
      | uname == "Bob" = Rec {uid = (idn+1), name = (uname ++ "+1")}
      | otherwise = ...
  </code></pre>
  
  <p>So is there some concise way to pattern match by record's field and assign its value at the same time?</p>
  
  <p><strong>Note</strong>: I would like to avoid specific GHC's extensions.</p>