Diagonalization via codata