Parameterize your Haskell types! Sometimes.
Educational Session (50m)
Intermediate
Ever experimented with parameterized types? This talk explores how you can use parameterized types to enhance the expressiveness of your data structures, with in-depth examples of how much you can express if you drink the Kool Aid.
In the strongly-typed world, everyone agrees we want to represent the space of possible values using an appropriate type. The only problem is there are so many techniques to choose from! There are vanilla records, row types, parameterized types, and more. So why choose parameterized types? The answer: profunctors!
In this talk, we'll weigh the tradeoffs of parameterizing types as opposed to alternatives before exploring the world of profunctors, and how they enable a richer coding vocabulary for defining everyday data structures/working with deeply nested configuration files. We will see how to solve this common problem in software development using FP techniques and a new library built for this purpose: Interpolator. Interpolator is a new library that uses these techniques to provide a well-typed interface for substitution of runtime values into a nested data structure, without having to redefine the types. We'll get to work defining the necessary records, instances, and type aliases, and investigate several examples with increasing complexity.
NOTE While "profunctor" may seem like a scary word, hopefully this talk will eliminate some of its mystique. Specifically, we'll make sure that everyone understands what a profunctor does before moving on. This talk expects the attendee to have experience with Haskell. While not the focus of this talk, applicatives, monads, and monad transformers will make appearances.
Parameterizing types is compelling in particular because it has proven to be an effective interface for abstracting database tables in the Opaleye library, and I want to draw upon the motivations, similarities, and differences for it in the Interpolator library. My hope is that by showing these similarities in a simpler setting others will be less intimidated by so called "advanced" concepts like profunctor.
- Haskell
- Type theory
- Generic programming
Great concept! Wish I had (helped) come up with it :-D
What do you think about flipping the pitch a bit so it's something like "Learn how to define your data in a simple way and get runtime configuration for free — plus see how Profunctor surprisingly saves the day"? I think that might bring in people who don't know they want to learn about Profunctor. To be honest, I still don't really understand how Profunctor solves this problem, so I obviously need to go to this talk.