Cores of dark matter haloes correlate with stellar scalelengths