An explanation of how parameterized datatypes are injective in Haskell while type families are not, and how to use injective type families.
In this episode, we will discuss in what way parameterised datatypes are injective and type families are not. For this episode, we assume familiarity with Haskell fundamentals, in particular datatypes. Knowledge of type families is certainly helpful, but not required.
Resources:
- Repository where the code will be made available after the episode: github.com/well-typed/unfolder
- Paper: "Injective Type Families", Jan Stolarek, Simon Peyton Jones, Richard Eisenberg, Haskell Symposium 2015, microsoft.com/en-us/research/wp-content/uploads/2016/07/inje…
If you are interested in the topics discussed in this episode, Well-Typed offers a course on Haskell's / GHC's type system (as well as other courses). well-typed.com/training_type_system/
- Introduction
- Title sequence
- Definition of injectivity and examples
- Injectivity of parameterised Haskell datatypes
- Proxy
- Example where ambiguity can arise
- Example where injectivity is essential
- Switching to a type family
- AllowAmbiguousTypes
- Explicit type applications
- Using proxy to direct the type checker
- Why proxies are better than plain explicit type applications
- Revisiting the Encryption example from Episode 2
- Injectivity annotations / type family dependencies
- Questions
- Defining your own (partial) inverse
- End
Why it's here
1 person recommends this
What people say. Recommended as a helpful guide to understanding injectivity and type families in Haskell.
k
u/kosmikusin r/haskell • Recommends
The Haskell Unfolder Episode 3: injectivity
Today, 2023-05-15, at 1830 UTC (11:30 am PDT, 2:30 pm EDT, 7:30 pm BST, 20:30 CEST, …) we are streaming the third episode of the Haskell Unfolder live on YouTube:
[video
In this episode, we will discuss in what way parameterised datatypes are injective and type families are not. For this episode, we assume familiarity with Haskell fundamentals, in particular datatypes. Knowledge of type families is certainly helpful, but not required.
The Haskell Unfolder is a YouTube series about all things Haskell hosted by Edsko de Vries and Andres Löh, with episodes appearing approximately every two weeks. The playlist containing all episodes so far is he…