Today's dependently typed languages that emphasize correct-by-construction programming (e.g. Agda, Epigram, Idris) are "both a blessing and a curse". On one hand, creating specialized indexed datatypes allows functions to be written over the minimal and exact cases a function is expected to handle. On the other hand, constantly creating new datatypes comes with the cost of constantly rewriting routine functions. Fortunately, a beautiful solution to this problem exists in the form of datatype Ornaments (McBride?). Unfortunately, no existing programming language supports them. I will present a dependent type theory that makes datatype definitions first-class, hence supporting Ornaments and other features as user-libraries (rather than being baked into the meta theory). This is the idea behind Levitation (Chapman et al), but presented as a stratified denotational semantics for the types of such a language.
Agda code used in this talk: