Type-level representation of edge cardinality constraints

This is a work in progress. Will write a detailed report when it's finished.