My probability text first introduces indicator functions $I_A(\omega)$ as being 1 when $\omega \in A$ and 0 otherwise, where $A$ is an event (a subset of the sample space $\Omega$). So you can say $I_A : \Omega \mapsto \lbrace 0,1 \rbrace$.
Later it introduces the notion of random variables and the following notational sugar for comparisons against them:
$$\mathbb{P}(X \in A) = \mathbb{P}(X^{-1}(A)) = \mathbb{P}(\lbrace \omega : X(\omega) \in A\rbrace)$$ $$\mathbb{P}(X \leq x) = \mathbb{P}(\lbrace \omega : X(\omega) \leq x\rbrace)$$
Etc. Later in the expectation chapter it has the following identity:
Let $A$ be an event and let $I_A(x) = 1$ if $x \in A$ and $I_A(x) = 0$ if $x \notin A$. Then:
$$\mathbb{E}(I_A(X)) = \int I_A(x)f_X(x)dx = \int_A f_X(x)dx = \mathbb{P}(X \in A)$$
I'm not quite sure how to desugar/interpret $I_A(X)$. The expectation function takes a random variable, and an indicator function as defined at the beginning of the book qualifies as a random variable because it maps outcomes to reals. But here they're passing a random variable into the indicator function, not an outcome, so the types don't match. I thought maybe it could mean this:
$$\mathbb{E}(\lbrace I_A(\omega) : \omega \in X^{-1}(A) \rbrace)$$
But that doesn't work because I know the result must be a random variable (not a set) because that's what $\mathbb{E}$ takes. I would be tempted to interpret the $A$ in $I_A$ to be a subset of the real line rather than an event in the context of the identity, but my text specifically identifies it as an event.
How do I make the types make sense?