Refracting or diffracting devices, e.g. lens, prism comprising plurality of wave-guiding channels of different length