We propose a novel approach for the determination of the nature of ultra-high energy cosmic rays by exploiting the geomagnetic deviation of muons in nearly horizontal showers. The distribution of the muons at ground level is well described by a simple parametrization providing a few shape parameters tightly correlated to $X^mu_mathrm{max}$, the depth of maximal muon production, which is a mass indicator tightly correlated to the usual parameter $X_mathrm{max}$, the depth of maximal development of the shower. We show that some constraints can be set on the predictions of hadronic models, especially by combining the geomagnetic distortion with standard measurement of the longitudinal profile. We discuss the precision needed to obtain significant results and we propose a schematic layout of a detector.