Talk: Algebraic Data Types for C#

If you use C# in your day job, and hate having to leave your ADTs behind, you don't have to! Come and see how you can incorporate sum and product types into your existing C# projects.

A significant number of professional developers use C#, which does not natively support immutable sum and product types. Immutable algebraic data types are an invaluable tool for proper problem modeling, because they focus on keeping illegal states from being representable. This talk is about how to practically introduce ADTs into C# by the use of DSLs and code generation. We will dive into how ADTs can be represented, implemented with native C# constructs, and used with pattern matching and partial modification. We’ll conclude with the mechanics of parsing and code generation, look at an open source library and tool, and discuss practical integration of FP patterns into daily work in C#.

Immutable algebraic data types are an invaluable tool for proper problem modeling, because they focus on keeping illegal states from being representable. However, many programmers who use C# in their day jobs do not get the benefits of these types. This talk will:
1. Briefly introduce ADTs and their use (most people at LC would already know this).
2. Discuss how a Product and Union Type can each be implemented with classes.
3. Talk about Value Semantics and how to implement it with classes.
4. Introduce a code generator to generate the boilerplate.
5. Introduce a DSL to represent Product and Union Types and hook it up to the code generator.
6. Integrate the whole thing into Visual Studio to provide a seamless extension to allow using ADTs within existing C# projects.
7. Extend a DU defined in the DSL with C# to provide type-class support for Functor, Applicative and Monad, and integrate into LINQ to show that the generated code is extensible.

Rate this talk via Messenger