In my recently released Pluralsight course, Building F# Type Providers, I show how to build a type provider that uses erased types. To keep things simple I opted to not include any discussion of generative type providers beyond explaining the difference between type erasure and type generation. I thought I might get some negative feedback regarding that decision but I still believe it was the right decision for the course. That said, while the feedback I’ve received has been quite positive, especially for my first course, I have indeed heard from a few people that they would have liked to see generated types included as well.
There are a number of existing type providers that use generated types, most notably in my opinion is the SqlEnumProvider from FSharp.Data.SqlClient. That particular type provider generates CLI-enum or enum-like types which represent key/value pairs stored in the source database.
Although SqlEnumProvider is a great example and is relatively easy to follow, general how-to documentation for generative type providers is hard to come by to say the least. As such I thought that showing how to write the ID3Provider built in the course as a generative type provider would be a nice addendum for the course material. I clearly won’t be covering everything I do in the course here so if you’re looking for a deeper understanding of type providers I strongly encourage you to watch it before reading this article. (more…)