Please log in to watch this conference skillscast.
F#'s erasing type providers are a ground-breaking feature that (amongst other things) remove the need for a whole lot of boilerplate code which you would otherwise have to write or generate. Does this mean that you never have a need to generate code in F#? Of course it doesn't! Unfortunately, F# has no real code-generation story, other than generative type providers - which are hard to write and extremely limited with what they can generate. if you want to generate some record types that bridge the gap between the erasing type providers and the rest of your program, you are going to have to do it manually or write a code generator yourself.
The new Mixin type provider – which is not really a type provider at all in the traditional sense - leverages the existing type provider infrastructure and allows you to evaluate compile-time F# metaprograms. These metaprograms, with the help of a compositional code generation DSL, produce F# code that is then compiled into assemblies. In this manner, we can write idiomatic style F# and easily produce everything from
[<Literal>] values to feed other type providers, to record types and discriminated unions, even computation expressions and other type providers!
Powering these metaprograms with existing erasing type providers and F# libraries, then bringing everything together within the standard F# compilation pipeline, the Mixin provider delivers a powerful code generation story for F#. Plus, the code generation DSL is called SquirrelMix, which should be enough to warrant you coming to this talk on its own.
YOU MAY ALSO LIKE:
- YOU WERE EATEN BY A GRUE - Audience Level: Advanced (SkillsCast recorded in April 2017)
- Functional Concurrency in .NET with C# and F# with Riccardo Terrell (Online Course on 8th - 11th March 2021)
- F# eXchange 2021 (Online Conference on 20th - 21st October 2021)
- F# for a Real World E-commerce Project (SkillsCast recorded in October 2020)
- Rethinking Bioinformatic Algorithms Using F# (SkillsCast recorded in October 2020)
Meta-Programming Madness with the Mixin Type Provider
Ross has been accidentally wiping hard drives and melting transistors into his fingers since he can remember. He has over 20 years programming experience in a wide variety of different languages and technologies, ranging from games and financial markets to fraud prevention and investigation. He has more recently been working on F# type providers. He loves squirrels, physics, electronics, robotics, functional programming, programming languages in general and squirrels.