Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is necessary from a language implementation point of view to implement type providers like in F# 3.0?

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#?

like image 869
soc Avatar asked Sep 15 '11 09:09

soc


People also ask

What are implementation methods in the programming language?

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.

What are the most relevant methods of implementing programming languages?

Three general methods of implementing a programming language are compilation, pure interpretation, and hybrid implementation.


1 Answers

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).

like image 169
Tomas Petricek Avatar answered Sep 20 '22 19:09

Tomas Petricek