Type Providers are a mature language feature of F# 3 that provide instant typed access, with code completion, to a wide variety of data sources, without requiring code generation. As a language feature, F# Type Providers are cross platform, meaning they can be accessed on Windows via .Net, or on Mac and Linux using the Mono runtime.
If you’re interested in using Type Providers pop down to Skills Matter this Thursday for a Type Provider Treasure Hunt with Tomas Petricek, or Creating Type Providers Hands On with Michael Newton on May 1st.
CSV, JSON and XML Type Providers are all available from the community open source FSharp.Data project.
What’s the weather like in London now?
type Weather = JsonProvider< "weather.json" >
let url = "http://api.openweathermap.org/data/2.5/weather?units=metric&q="
let weather = Weather.Load(url+"London")
Nuget stats on FSharp.Data from an HTML table?
type NugetStats = HtmlProvider<"https://www.nuget.org/packages/FSharp.Data">
let rawStats = NugetStats().Tables.Table0
Early type providers allowed access to SQL databases via a connection string, DBML and EDMX files or Entity framework.
The open source SqlClient provider lets you explore queries, stored procedures, user defined types and functions with intellisense.
Access to MS SQL Server, SQLite, PostgreSQL, Oracle and MySQL with full LINQ support is made possible with Ross McKinlay’s SQLProvider.
Connect to the cloud with Isaac Abraham’s Azure Storage Provider.
Or connect to a community-curated database of well-known people places and things with the Freebase provider:
let fb = FreebaseData.GetDataContext()
let astronomy = fb.Society.Celebrities.``Abused substances``
Interop seamlessly with the R statistical programming language with the R Type Provider:
let v = R.c(1,2,3)
Or Matlab, or Java, or Python.
It all started with Ross’s Choose Your Own Adventure Type Provider, and then there was MineSweeper and Battleships.
Now thanks to James you can enjoy FizzBuzz as a Type Provider too: