We study a class of measure-theoretic objects that we call cubic couplings, on which there is a common generalization of the Gowers norms and the Host–Kra seminorms. Our main result yields a complete structural description of cubic couplings, using nilspaces. We give three applications. Firstly, we describe the characteristic factors of Host–Kra type seminorms for measure-preserving actions of countable nilpotent groups. This yields an extension of the structure theorem of Host and Kra. Secondly, we characterize sequences of random variables with a property that we call cubic exchangeability. These are sequences indexed by the infinite discrete cube, such that for every integer
k
≥
0
k\geq 0
the joint distribution’s marginals on affine subcubes of dimension
k
k
are all equal. In particular, our result gives a description, in terms of compact nilspaces, of a related exchangeability property considered by Austin, inspired by a problem of Aldous. Finally, using nilspaces we obtain limit objects for sequences of functions on compact abelian groups (more generally on compact nilspaces) such that the densities of certain patterns in these functions converge. The paper thus proposes a measure-theoretic framework on which the area of higher-order Fourier analysis can be based, and which yields new applications of this area in a unified way in ergodic theory and arithmetic combinatorics.