This is an oxidation-reduction (redox) reaction:
2 HI + 2 e- → 2 H0 (reduction)
Mg0 - 2 e- → MgII (oxidation)
Reactants:
Products: