F# 3.0 adds type providers, which make it basically unnecessary to manually write or generate mappings between a DB (or another data provider) and the language/type system, because the language can query structural information from the database itself directly with type providers.
What is necessary from a language implementation point of view to add such a feature to a language?
Does it require a fully pluggable type system? Or is it more like some hidden code generator integrated into the compiler?
What's necessary to implement a new type provider for F#?
There are two general approaches to programming language implementation: Interpretation: The program is read as input by an interpreter, which performs the actions written in the program. Compilation: The program is read by a compiler, which translates it into some other language, such as bytecode or machine code.
Three general methods of implementing a programming language are compilation, pure interpretation, and hybrid implementation.
Technically, you can think of F# type providers as "plugins" for the compiler. Instead of generating mappings, the compiler asks the type provider "What types do you know?" or "Do you know this type?" (depending on the context).
The plugin (type provider) answers and specifies what the type looks like (abstractly, without actually generating it). The compiler then works with this information and later asks the type provider to provide code that should be used when compiling code that uses these "fake" types. It is also possible to actually generate code (some samples do this, because they just use tools that are already there).
So yes, you can implement your own type provider. I said a few things about it in the GOTO Copenhagen talk which has been recorded and Don Syme said a few things in his earlier talks (I didn't see his BUILD talk yet).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With