Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do type providers exist in other languages except F#?

I've been stuck on this for a few days now... Sorry for such a question, but I'm just a beginner in F# itself. As there are a lot of discussions about type providers I decided to build one and write a paper about it. When I began I had no idea what type provider is. Now I have some idea and I have built a simple CSV type provider, but I lack arguments in the evaluation about, how much time and work would it take to make something like this in other languages. So far I haven't found any clue about it, just that type provider is a feature in F# 3.0. Can anyone help me out, please?

like image 472
janix89 Avatar asked Nov 26 '17 16:11

janix89


1 Answers

As far as I know, the only other language that directly implements type providers is Idris. See the Idris documentation on type providers. There are some examples, including SQL type provider in David Christiansen's GitHub repo. As a dependently typed language, type providers have quite a different look than in F# - they are basically computations in the IO monad that are invoked using the %provide command - so they are a bit more uniform with the rest of the language compared to the F# design.

There are other language features that are related to type providers.

  • This includes various templating systems (such as Template Haskell and camplp4 for OCaml). These lack some of the type provider features (they actually generate code, so you cannot provide "infinite size" types and they are not as integrated with the tooling).

  • There are lots of code generation tools for languages such as Java and C# (LINQ to SQL uses code generation and various UI frameworks do too), but again, this lacks the language integration and can only support types that are relatively small.

  • Another relevant thing is meta-programming such as multi-stage programming, but as far as I can say, this is mostly just academic and there is no solid language implementing this.

It is difficult to say which of these are close to type providers. For me, the essential feature of type providers is the quick feedback I get as a developer when using them (and for some, this means updating schema on the fly during development) - and that's something that code generation tools generally do not do. The other - being able to provide infinite number of types lazily is useful for some type providers, but not for all - so e.g. JSON, XML or CSV could be reasonably handled by a code generation tool.

like image 106
Tomas Petricek Avatar answered Oct 19 '22 02:10

Tomas Petricek