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)
- Real World Kotlin Development Workshop (in London on 22nd - 23rd October 2019)
- Lightbend Akka for Scala - Professional (in London on 11th - 12th November 2019)
- Clojure eXchange 2019 (in London on 2nd - 3rd December 2019)
- Scala eXchange London 2019 (in London on 12th - 13th December 2019)
- Code Kata: Yilin Wei - Optics with Monocle (in London on 22nd October 2019)
- Keynote by Konrad Kokosa: What’s New in .NET Core 3.0 and .NET 5.0 for Performance and Memory-Aware Folks? (in London on 29th October 2019)
- Keynote: (Programming Languages) in Agda = Programming (Languages in Agda) (SkillsCast recorded in October 2019)
- Keynote: Haskell is a Great Host (SkillsCast recorded in October 2019)
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.