4 ms·
> This appears to be just outsourcing the record schema definition to a sample object in another file. Not quite. There's an interface called IProvidedTypes th
by phillipcarter 7y ago
> This appears to be just outsourcing the record schema definition to a sample object in another file.
Not quite. There's an interface called IProvidedTypes that a component - a Type Provider - is responsible for conforming to. That component reads data of some kind and produces information in that interface. The F# compiler then takes that data and includes it in the set of symbols that it calculates for everything else in your codebase. The end result is that you get typed access to data with zero configuration aside from adding a package, and because this data is exposed to tooling, you get IntelliSense for it in your editor as the blog post shows. The paper about the subject is here: http://tomasp.net/academic/papers/fsharp-data/fsharp-data.pdf http://tomasp.net/academic/papers/fsharp-data/fsharp-data.pd...
> You still have to keep that sample updated to handle new runtime data.
This is only if you're working with a sample. In most cases, developers just point it at the real data source and program against that - the target URL for a JSON payload, the connection string to the SQL database, etc. There's still issues that can arise, such as a poorly-written Type Provider, but the most popular ones are well-written and won't do silly things like slurp in your whole database into memory.