Rigid type variables
- Background
- Mismatches
- Scoped type variables
- Instances
The phrase rigid type variable shows up in several contexts in GHC error messages. Often, when it appears, it’s in a context where you know that the type variable it refers to is totally unconstrained, or parametrically polymorphic, and you may have found yourself wondering what is exactly is meant by rigid? How can something that could be anything be “rigid”?
You have come to the right place.
Background
Briefly, the phrase rigid type variable can be traced back at least to 2004, Wobbly Types: Type Inference For Generalised Algebraic Data Types by Simon Peyton Jones, Geoffrey Washburn, Stephanie Weirich. to a paper contrasting rigid types with “wobbly types”, that is, types that the compiler has to guess at. A later paper, published in 2006 suggested that the other name considered for rigid type was user-specified type. The authors report,For a full discussion of the precise meaning of “rigid type variable” and why this phrase was chosen, please see the paper “Simple unification-based type inference for GADTs” by Dimitrios Vytiniotis, Stephanie Weirich, and Simon Peyton Jones.
we use the briefer term rigid type to describe a type that is completely specified, in some direct fashion, by a programmer-supplied type annotation.
Although this isn’t the original intent, we like to think of the phrase “user specified” as indicating how the type variable can finally unify with a concrete type: when it’s used.