TITLE: Have mathematical structures equipped with "generalized relations" been considered in a systematic way?
QUESTION [7 upvotes]: A binary relation on $X$ is basically just a function $X^2 \rightarrow \mathbb{B}$, where $\mathbb{B}$ is the prototypical Boolean algebra $\{0,1\}.$ We can generalize by replacing $\mathbb{B}$ with a more complicated partially ordered structure. Thus, we have:
Heuristic idea. A generalized relation on $X$ is a function $X^n \rightarrow P$, where $P$ is a partially ordered set possibly having additional structure.
For example, a metric space can be viewed as set $X$ equipped with a generalized relation $d : X^2 \rightarrow [0,\infty)$ satisfying the usual axioms.
Question. Have mathematical structures equipped with generalized relations been considered in a systematic way? A reference would be nice.

Discussion. Here's the example I am most interested in.
Suppose $X$ and $Y$ are sets, and that $R$ is a binary relation on $Y$. That is, $R$ is a function $Y \times Y \rightarrow \mathbb{B}$. Then the family $Y^X$ can naturally be equipped with a generalized binary relation $R' : Y^X \times Y^X \rightarrow \mathbb{B}^X$ defined by asserting that $R'(f,g)$ equals the characteristic function of
$$\{x \in X \mid R(f(x),g(x))\}.$$
Anyway, the point is that if $\mathcal{Y} = (Y,R)$ is a relational structure, then really $\mathcal{Y}^X$ is most naturally viewed as equipped not with a relation $R'$ having codomain $\mathbb{B}$, but rather a generalized relation having codomain $\mathbb{B}^X.$ We might call such a beast a "generalized relational structure."
Metric spaces presumably undergo a similar generalization, although I'm still trying to work out the details.

REPLY [2 votes]: I've thought about that idea as well.  I don't think that there's a systematic theory along those lines.  This might mean that there's nothing to be said in full generality.  A single generalized relation is the same as a family of relations $P_i$ such that $P_i \implies P_j$ for $i \leq j$, so in some sense you don't get anything new.
You do see applications of the idea around mathematics.  Lord Farin already mentioned Boolean-valued and Heyting-valued models.  Another variant comes from theoretical computer science, and goes by the name domain theory.  Computable functions are modeled as functions on a partially-ordered set.  Functions higher in the partial order are "more defined" than functions lower.
For the specific application of metric spaces, there has been some development along the lines you have in mind.  Look for "Lawvere metric spaces".  The idea is expressed in category-theoretic language, but the underlying notion is the same as what you have in mind.