Warning: this is probably only of interest to functional programmers. Maciej Kotowicz recently asked on the Haskell Cafe mailing list about implementing binomial queues (also known as binomial heaps ) using fancy type machinery so that the type-checker can enforce the shape invariants of the data structure. This reminded me of a discussion I had with some colleagues in the summer of 1998 about using nested types to enforce these kinds of invariants. A little digging around in mail archives yielded this email, presented here with some light formatting and a few fixed typos. I've been playing with binomial queues as a nested type, and I think you'll find the end result interesting.
From HaskellWiki < GHC (Redirected from GHC/Indexed types ) Indexed type families, or type families for short, are a Haskell extension supporting ad-hoc overloading of data types. Type families are parametric types that can be assigned specialized representations based on the type parameters they are instantiated with. They are the data type analogue of type classes : families are used to define overloaded data in the same way that classes are used to define overloaded functions .