Yesterday F# 3.0 Developer Preview became available at the MSDN Site. It will be general available on Friday.
One of the new features is the type provider.
This little snippet shows how easy it is to query a site that provides oData. NuGet is an example of a site that provides oData.
Code Snippet
- #r "FSharp.Data.TypeProviders.dll"
- #r "System.Data.Services.Client.dll"
- open Microsoft.FSharp.Data.TypeProviders
- [<Generate>]
- type NuGet = ODataService<"http://packages.nuget.org/v1/FeedService.svc/">
- let dbNuGet = NuGet.GetDataContext()
- let packages = dbNuGet.Packages
- let nuGetQuery =
- query { for package in packages do
- where (package.Tags.Contains("fsharp") && package.IsLatestVersion)
- select package }
- let printPackage (package:NuGet.ServiceTypes.PublishedPackage) =
- printfn "- - - - - - - - - - - - - - - - - - - -"
- printfn "Title: %s" package.Title
- printfn "Authors: %s" package.Authors
- printfn "Description: %s" package.Description
- nuGetQuery |> Seq.iter printPackage
This is the result:
One of the nice features of type providers is intellisense for the available types.
It is possible to create your own type provider.
More information will be available on Friday. Don Syme will present all the details at build: http://channel9.msdn.com/events/BUILD/BUILD2011/SAC-904T
update: Writing F# Type Providers with the F# 3.0 Developer Preview - An Introductory Guide and Samples