I've been casually reading about optimal transport, and I was intrigued by the Wasserstein metric, in which we define the distance between two measures $\mu$ and $\nu$ on a metric space $X$ by $$ W_p(\mu, \nu) = \left(\inf_\gamma \int_{X\times X} \mathrm{dist}(x,y)^p \mathrm{d}\gamma(x,y)\right)^{1/p}, $$ where the infimum is taken over all measures $\gamma$ on $X\times X$ whose projections onto the respective factors give $\mu$ and $\nu$.
It occurred to me that this appears to provide a framework to generalize the notion of functions altogether. In particular, for a measure space $X,\mu$, we could define a generalized function from $X$ to $Y$ as a measure $\gamma$ on $X\times Y$ such that $\pi_* \gamma = \mu$, where $\pi:X\times Y\rightarrow X$ is the projection to the first factor.
We can then try to define all the usual operations on functions in this new framework. For instance, for generalized funcitons $\gamma_1$ from $X$ to $Y$ and $\gamma_2$ from $Y$ to $Z$, we could try to define $\gamma_2\circ \gamma_1$ by $$ \gamma_2\circ \gamma_1 (A\times C) = \sum_{y\in Y}\gamma_1(A\times \{y\})\gamma_2(\{y\}\times C).$$ Of course, this only works if $Y$ is finite (or countable). I believe there should be a generalization of this to arbitrary $Y$ using integrals, but I am having trouble coming up with a good formulation. Apparently you can use Markov chains, but I am still trying to understand how to write this down cleanly.
In any case, I am interested in whether this notion provides a useful way to generalize functions. How much of the usual theory carries over? Could this be used e.g. to study weak solutions to PDEs, to study the monodromy of solutions to algebraic equations, or to study backwards iteration in otherwise non-invertible dynamical systems?