We use generic programming techniques to generate well-typed lambda terms. We encode well-typed terms by generalized algebraic datatypes (GADTs) and existential types. The Spine approach to generic programming supports GADTs, but it does not support the definition of generic producers for existentials. We describe how to extend the Spine approach to support existentials and we use the improved Spine to define a generic enumeration function. We show that the enumeration function can be used to generate the terms of simply typed lambda calculus.
Rodriguez Yakushev & Jeuring REF study the feasibility of generic programming for the enumeration of typed terms.
Enumerating Well-Typed Terms Generically
AAIP
Computer Science