title: How can I determine the json path to a field within a record without actually hard coding the path?
body: <p>I would like to work with the following type</p>
  <pre><code>type RecordPath&lt;'a,'b&gt; = {
      Get: 'a -&gt; 'b
      Path:string
  }
  </code></pre>
  <p>It's purpose is to define a getter for going from record type <code>'a</code> to some field within <code>'a</code> of type <code>'b</code>. It also gives the path to that field for the json representation of the record.</p>
  <p>For example, consider the following fields.</p>
  <pre><code>type DateWithoutTimeBecauseWeirdlyDotnetDoesNotHaveThisConcept = {
      Year:uint
      Month:uint
      Day:uint
  }
  
  type Person = {
      FullName:string
      PassportNumber:string
      BirthDate:DateWithoutTimeBecauseWeirdlyDotnetDoesNotHaveThisConcept
  }
  
  type Team = {
      TeamName:string
      TeamMembers:Person list
  }
  </code></pre>
  <p>An example <code>RecordPath</code> might be</p>
  <pre><code>let birthYearPath = {
      Get = fun (team:Team) -&gt; team.TeamMembers |&gt; List.map (fun p -&gt; p.BirthDate.Year)
      Path = &quot;$.TeamMember[*].BirthDate.Year&quot; //using mariadb format for json path
  }
  </code></pre>
  <p>Is there some way of letting a library user create this record without ever actually needing to specify the string explicitly. Ideally there is some strongly typed way of the user specifying the fields involved. Maybe some kind of clever use of reflection?</p>
  <p>It just occurred to me that with a language that supports macros, this would be possible. But can it be done in F#?</p>
  <p>PS: I notice that I left out the s in &quot;TeamMembers&quot; in the path. This is the kind of thing I want to guard against to make it easier on the user.</p>