1 people like it.

F# Data type providers

Reading the F# snippets RSS feed using the F# Data XML type provider. Look, you now get tool tips for type providers too!

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
#r "FSharp.Data.dll"
#r "System.Xml.Linq.dll"
open FSharp.Data

type Rss = XmlProvider<"http://fssnip.net/pages/Rss">
let snippets = Rss.GetSample()

// Title.Value is a property returning string 
printfn "%s" snippets.Channel.Title.Value

// Get all item nodes and print title with link
for item in snippets.Channel.Items do
  printfn " - %s (%s)" item.Title.Value item.Link
Multiple items
namespace FSharp

--------------------
namespace Microsoft.FSharp
Multiple items
namespace FSharp.Data

--------------------
namespace Microsoft.FSharp.Data
type Rss = XmlProvider<...>

Full name: Script.Rss
type XmlProvider

Full name: FSharp.Data.XmlProvider


<summary>Typed representation of a XML file.</summary>
       <param name='Sample'>Location of a XML sample file or a string containing a sample XML document.</param>
       <param name='SampleIsList'>If true, the children of the root in the sample document represent individual samples for the inference.</param>
       <param name='Global'>If true, the inference unifies all XML elements with the same name.</param>
       <param name='Culture'>The culture used for parsing numbers and dates. Defaults to the invariant culture.</param>
       <param name='Encoding'>The encoding used to read the sample. You can specify either the character set name or the codepage number. Defaults to UTF8 for files, and to ISO-8859-1 the for HTTP requests, unless `charset` is specified in the `Content-Type` response header.</param>
       <param name='ResolutionFolder'>A directory that is used when resolving relative file references (at design time and in hosted execution).</param>
       <param name='EmbeddedResource'>When specified, the type provider first attempts to load the sample from the specified resource
          (e.g. 'MyCompany.MyAssembly, resource_name.xml'). This is useful when exposing types generated by the type provider.</param>
       <param name='InferTypesFromValues'>If true, turns on additional type inference from values.
          (e.g. type inference infers string values such as "123" as ints and values constrained to 0 and 1 as booleans. The XmlProvider also infers string values as JSON.)</param>
val snippets : XmlProvider<...>.Rss

Full name: Script.snippets
XmlProvider<...>.GetSample() : XmlProvider<...>.Rss
val printfn : format:Printf.TextWriterFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
property XmlProvider<...>.Rss.Channel: XmlProvider<...>.Channel
property XmlProvider<...>.Channel.Title: XmlProvider<...>.Title
property XmlProvider<...>.Title.Value: string
val item : XmlProvider<...>.Item
property XmlProvider<...>.Channel.Items: XmlProvider<...>.Item []
property XmlProvider<...>.Item.Title: XmlProvider<...>.Title2
property XmlProvider<...>.Title2.Value: string
property XmlProvider<...>.Item.Link: string

More information

Link:http://fssnip.net/tO
Posted:8 years ago
Author:Tomas Petricek
Tags: type providers , f# data