  The toric code can be constructed as a gauge theory of finite groups on
oriented two dimensional lattices. Here we construct analogous models with the
gauge fields belonging to groupoids, which are categories where every morphism
has an inverse. We show that a consistent system can be constructed for an
arbitrary groupoid and analyze the simplest example that can be seen as the
analog of the Abelian $\mathbb{Z}_2$ toric code. We find several exactly
solvable models that have fracton-like features which include an extensive
ground state degeneracy and excitations that are either immobile or have
restricted mobility. Among the possibilities we study in detail the one where
the ground state degeneracy scales as $2\times 2^{N_v}$, where $N_v$ is the
number of vertices in the lattice. The origin of this degeneracy can be traced
to loop operators supported on both contractible and non-contractible loops. In
particular, different non-contractible loops, along the same direction on a
torus, result in different ground states. This is an exponential increase in
the number of logical qubits that can be encoded in this code. Moreover the
face excitations in this system are deconfined, free to move without an energy
cost along certain directions of the lattice, whereas in certain other
directions their movement incurs an energy cost. This places a restriction on
the types of loop operators that contribute to the ground state degeneracy. The
vertex excitations are immobile. The results are also extended to the groupoid
analogs of Abelian $\mathbb{Z}_N$ toric codes.
