  The dimer model is the study of random dimer covers (perfect matchings) of a
graph. A double-dimer configuration on a graph $G$ is a union of two dimer
covers of $G$. We introduce quaternion weights in the dimer model and show how
they can be used to study the homotopy classes (relative to a fixed set of
faces) of loops in the double dimer model on a planar graph. As an application
we prove that, in the scaling limit of the "uniform" double-dimer model on
${\mathbb Z}^2$ (or on any other bipartite planar graph conformally
approximating $\mathbb C$), the loops are conformally invariant.
  As other applications we compute the exact distribution of the number of
topologically nontrivial loops in the double-dimer model on a cylinder and the
expected number of loops surrounding two faces of a planar graph.
