At the first FP Day on Friday, I attended a
talk by Don Syme on F#
There were a number of useful features, but to the functional
programmer, the most revolutionary one was type providers. They’re a way
to use strong, static typing for data structures beyond those coded into
libraries. The most prominent use of these are for data sets so large
that the entire set of types necessary to understand all of it is too
much to include in your application. However, they’re also useful as an
alternative to code generation. Take for example, accessing a page on
Wikipedia. If I have a type provider that accesses Wikipedia as I’m
writing the code and generates types for each type of article, I can do
something like this.
FYI (because most of us don’t know F#), backticks (
`) let you
put spaces in names, angle brackets (
>) are used to
initialise type providers, and the
|> operator pipes the result of
one operation into the next.
type Wikipedia = Wikipedia<>
.``History of computing``
|> String.concat ", "
|> (+) "Dennis Ritchie was known for "
// returns "Dennis Ritchie was known for ALGOL, B, BCPL, C, Multics, Unix"