We report the detection of emission in the J=1-0 rotational transition of hydrogen fluoride (HF), together with observations of the J=1-0 to J=3-2 rotational lines of H35Cl and H37Cl, towards the envelope of the carbon star IRC +10216. High-sensitivity, high-spectral resolution observations have been carried out with the HIFI instrument on board Herschel, allowing us to resolve the line profiles and providing insights into the spatial distribution of the emission. Our interpretation of the observations, with the use of radiative transfer calculations, indicates that both HF and HCl are formed in the inner regions of the envelope close to the AGB star. Thermochemical equilibrium calculations predict HF and HCl to be the major reservoirs of fluorine and chlorine in the atmospheres of AGB stars. The abundances relative to H2 derived for HF and HCl, 8e-9 and 1e-7 respectively, are substantially lower than those predicted by thermochemical equilibrium, indicating that F and Cl are likely affected by significant depletion onto dust grains, although some chlorine may be in the form of atomic Cl. The H35Cl/H37Cl abundance ratio is 3.3 +/- 0.3. The low abundance derived for HF in IRC +10216 makes it likely that the fluorine abundance is not enhanced over the solar value by nucleosynthesis in the AGB star, although this conclusion may not be robust because the HF abundance we derive is a lower limit to the elemental abundance of F. These observations suggest that both HF and HCl should be detectable through low J rotational transitions in other evolved stars.