title: Creating a list of a provided type in F#
body: <p>I am trying to add a basic JSON type provider to <a href="https://github.com/fsharp/fsharpx" rel="nofollow">fsharpx</a>.
  At the moment I am struggeling with JSON Arrays. Consider the following test case:</p>
  
  <pre><code>type SimpleArray = JSON&lt; "{\"items\":[{\"id\":\"Open\"},{\"id\":\"Pause\"}]}"&gt;
  
  let a = SimpleArray()
  
  [&lt;Test&gt;] 
  let ``Can parse simple arrays``() = 
      a.items.[0].id
      |&gt; should equal "Open"
  
      a.items.[1].id
      |&gt; should equal "Pause"
  </code></pre>
  
  <p>The idea is that I want to use the first element in the array to get the type of the collection elements. Then I want to add a property "items" to the SimpleArray type that gives a list of this new type.</p>
  
  <p>The code can be found in the github repo <a href="https://github.com/fsharp/fsharpx/blob/TypeProviders/src/FSharpx.TypeProviders/JsonProvider.fs" rel="nofollow">Github</a>. The interesting part starts at line 38. As you can see the whole thing has to be recursive since the JArray could also contain nested JArrays.</p>
  
  <pre><code>| JArray list -&gt;
      let newType = annotateAsJson list.[0] (runtimeType&lt;obj&gt; (ownerTy.Name + "_" + e.Key))
      ownerTy.AddMember newType
      Some(provideProperty
              e.Key
              newType // TODO: make this a list
              (fun args -&gt; Expr.Coerce(&lt;@@ (%%args.[0] : obj) @@&gt;, newType)) // TODO: return the list
              :&gt; MemberInfo)
  </code></pre>
  
  <p>Thanks,
  Steffen</p>