title: Copy Properties Between Records
body: <p>Amongst several other State-related types, I have the following records types in my code:</p>
  
  <pre><code>type SubmittedSuggestionData = {
      SuggestionId : Guid
      SuggestionText : string
      Originator : User
      ParentCategory : Category
      SubmissionDate : DateTime
  }
  
  type ApprovedSuggestionData = {
      SuggestionId : Guid
      SuggestionText : string
      Originator : User
      ParentCategory : Category
      SubmissionDate : DateTime
      ApprovalDate : DateTime
  }
  </code></pre>
  
  <p>These then feed into the following:</p>
  
  <pre><code>type Suggestion = 
      | SubmittedSuggestion of SubmittedSuggestionData
      | ApprovedSuggestion of ApprovedSuggestionData
  </code></pre>
  
  <p>This gives me the ability to work with a State machine style pattern to carry out specific business logic dependent upon State. (This approach was taken from: <a href="http://fsharpforfunandprofit.com/posts/designing-with-types-representing-states/">http://fsharpforfunandprofit.com/posts/designing-with-types-representing-states/</a>)</p>
  
  <p>I have a function that in it's simplest form, changes a <code>SubmittedSuggestion</code> to an <code>ApprovedSuggestion</code>:</p>
  
  <pre><code>let ApproveSuggestion suggestion =
      match suggestion with
      | SubmittedSuggestion suggestion -&gt; ApprovedSuggestion {}
  </code></pre>
  
  <p>This function is incomplete at the moment as what I'm struggling to comprehend is when a Suggestion changes from Submitted to Approved, how do you copy the properties from the passed in <code>suggestion</code> into the newly created <code>ApprovedSuggestion</code> whilst also populating the new property of <code>ApprovalDate</code>? </p>
  
  <p>I guess it would work if I did something like:</p>
  
  <pre><code>let ApproveSuggestion suggestion =
      match suggestion with
      | SubmittedSuggestion {SuggestionId = suggestionId; SuggestionText = suggestionText; Originator = originator; ParentCategory = category; SubmissionDate = submissionDate} -&gt; 
          ApprovedSuggestion {SuggestionId = suggestionId; SuggestionText = suggestionText; Originator = originator; ParentCategory = category; SubmissionDate = submissionDate; ApprovalDate = DateTime.UtcNow}
  </code></pre>
  
  <p>but that looks pretty horrific to me.</p>
  
  <p>Is there a cleaner, more succinct way of getting the same outcome? I've tried using the <code>with</code> keyword but it didn't compile.</p>
  
  <p>Thanks</p>