This paper studies topological duals of locally convex function spaces that are natural generalizations of Fréchet and Banach function spaces. The dual is identified with the direct sum of another function space, a space of purely finitely additive measures and the annihilator of L^infty . This allows for quick proofs of various classical as well as new duality results e.g. in Lebesgue, Musielak–Orlicz, Orlicz–Lorentz space and spaces associated with convex risk measures. Beyond Banach and Fréchet spaces, we obtain completeness and duality results in general paired spaces of random variables.