What is the best way of typing an equation like this?

(The vertical red lines indicate three different alignment axes.)
I have tried the following:
\begin{alignat*}{3}
\phi: Z^{X \times Y} &\to (Z^Y)^X\\
f &\mapsto \phi(f): X &&\to Z^Y\\
x &&\mapsto \phi(f)(x): Y &&&\to Z\\
y &&&\mapsto \phi(f)(x)(y) = f(x,y)
\end{alignat*}
But it doesn't work well.


alignat, is illustrated in aligning equals as well as plus signs – barbara beeton Jun 02 '13 at 12:41