It’s all about the Type of the data

There have been a lot of rumours, and lots of demos that gave hints about the type providers that were to become available in F# 3.0. At last, a developer preview is here, and they do indeed look like a very powerful technology.

Type providers allow the user to register a provider, which will be called by the F# compiler at compile-time in order for the compiler to get information about types in the F# code that it is compiling. We’ve had tools in the past that you can point at a data source and which generate a .NET assembly of suitable types, but this has always been disconnected from the compiler running. With F# type providers, it is the compiler that drives the discovery process, making it possible to dynamically generate types of the right shape and avoid the need to generate data about types that aren’t called.

This post contains the best example of a type provider implementation that I have seen so far, showing how vector types could be provided for n-dimensional vectors where the n is specified in the source code.

This entry was posted in Computers and Internet. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s