  We study U(1) gauge theories with a modified Villain action. Such theories
can naturally be coupled to electric and magnetic matter, and display exact
electric-magnetic duality. In their simplest formulation without a
$\theta$-term, such theories are ultra-local. We extend the discussion to U(1)
gauge theories with $\theta$-terms, such that $\theta$ periodicity is exact for
a free theory, and show that imposing electric-magnetic duality results in a
local, but not ultra-local lattice action, which is reminiscent of the
L\"uscher construction of axial-symmetry preserving fermions in 4d. We discuss
the coupling to electric and magnetic matter as well as to dyons. For dyonic
matter the electric-magnetic duality and shifts of the $\theta$-angle by $2\pi$
together generate an SL$(2,\mathbb Z)$ duality group of transformations, just
like in the continuum. We finally illustrate how the SL$(2,\mathbb Z)$ duality
may be used to explore theories at finite $\theta$ without a sign problem.
