I'd like to have the command
\to produce the arrow from
\longrightarrow, but only when in a display mode, making use of the available space.
More precisely, the output of
So we have a map $A \to B$.
should be left unchanged, but
So we have a map \[ A \to B. \]
should produce the same as
So we have a map \[ A \longrightarrow B. \]
If possible, I'd like the same to happen to
\mapsto getting replaced by
\longmapsto when in display mode.