One of the most anticipated features of F# 3.0 is Type Providers. Type Providers make F# the best available option for working in an information-rich world. Even though the preview has only been available for a few days, there is already quite a bit of content covering Type Providers. Here are a few examples:
http://msdn.microsoft.com/en-us/library/hh156509(v=VS.110).aspx
http://blogs.msdn.com/b/fsharpteam/archive/2011/09/14/f-3-0-developer-preview-now-available.aspx
http://fsharp3sample.codeplex.com/
Here's a simple example of querying the StackOverflow OData feed using a Type Provider:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "FSharp.Data.TypeProviders" | |
#r "System.Data.Services.Client" | |
open Microsoft.FSharp.Data.TypeProviders | |
[<Generate>] // Only needed for the Developer Preview (this will be dropped before the official release of F# 3.0) | |
type stackoverflow = | |
ODataService<ServiceUri = @"http://data.stackexchange.com/stackoverflow/atom"> | |
let dataContext = stackoverflow.GetDataContext() | |
query { | |
for post in dataContext.Posts do | |
where (post.Tags.Contains "fsharp") | |
count | |
} |> printfn "There are %i posts marked with the fsharp tag on SO" |
How Do I Get It?
To start playing with F# 3.0, install the VS2011 dev preview and follow any of the step-by-step instructions provided at http://msdn.microsoft.com/en-us/library/hh156509(v=VS.110).aspx.
No comments:
Post a Comment