Cochains and homotopy type