Relating the mass function and internal structure of haloes