For abelian groups: does knowing $\text{Hom}(X,Z)$ for all $Z$ suffice to determine $X$? 
Let $X$ and $Y$ be abelian groups. Suppose $\text{Hom}(X,Z)\cong \text{Hom}(Y,Z)$ for all abelian groups $Z$. Does it follow that $X \cong Y$?

It has been answered before that this is true if the bijection $\text{Hom}(X,Z)\to \text{Hom}(Y,Z)$ is natural in $Z$. My intuition says that this assumption shouldn't be necessary. Maybe if we choose an extremely large and suitably "generic" group $Z$, then the structure of $\text{Hom}(X,Z)$ will somehow reveal the structure of $X$?
I'm also interested in the answer if "abelian group" is replaced by some other structure, in particular "$R$-module".
 A: I've just posted a negative answer (that I came across in the literature) on MathOverflow.
If $S=\mathbb{Z}^{(\omega)}$ is the direct sum of countably many copies of $\mathbb{Z}$ and $A=S\oplus\mathbb{Q}$ and $B=S\oplus\mathbb{Q}\oplus\mathbb{Q}$, then $A\not\cong B$, but $\operatorname{Hom}(A,Z)\cong\operatorname{Hom}(B,Z)$ for all abelian groups $Z$.
This seems to be due to Sebel'din (1974), and is a nice exercise to check.
A: I don't know how to answer this question for abelian groups, but I can answer it over some rings which have a very simple classification of all modules.  In particular, suppose $k$ is a field and $X$ and $Y$ are $k$-vector spaces such that $\operatorname{Hom}(X,Z)\cong\operatorname{Hom}(Y,Z)$ (as $k$-vector spaces) for all $k$-vector spaces $Z$.  Then it does follow that $X\cong Y$.
To prove this, suppose $X\not\cong Y$.  Without loss of generality we may assume $\dim X<\dim Y$; let $\kappa=\dim X$ and $\lambda=\dim Y$.  If $\kappa$ is finite the conclusion is trivial by taking $Z=k$, so suppose $\kappa$ is infinite.  Let $\mu$ be a strong limit cardinal greater than or equal to $|k|$ and of cofinality $\kappa^+$ and let $Z$ be a $k$-vector space of dimension $\mu$.  Then $|Z|=\mu$ so $|\operatorname{Hom}(X,Z)|=\mu^\kappa$ and $|\operatorname{Hom}(Y,Z)|=\mu^\lambda$.  But $\mu^\kappa=\mu$ since $\mu$ is strong limit and $\kappa<\operatorname{cf}(\mu)$, whereas $\mu^\lambda\geq\mu^{\kappa^+}=\mu^{\operatorname{cf}(\mu)}>\mu$.  Thus $\operatorname{Hom}(X,Z)$ and $\operatorname{Hom}(Y,Z)$ have different cardinalities, and so cannot be isomorphic.

We can generalize this a bit: the answer is also yes for $R$-modules if $R$ is a zero-dimensional principal ideal ring (in particular, for instance, this applies to $R=\mathbb{Z}/(n)$ for any $n>0$).  Such a ring is a finite product of local zero-dimensional principal ideal rings, and so we may assume $R$ is local.  In that case, $R$ has a nilpotent maximal ideal $m$, every ideal of $R$ is a power of $m$, and every $R$-module is a direct sum of cyclic modules.
So, any $R$-module has the form $$X\cong (R/m)^{\oplus\kappa_1}\oplus (R/m^2)^{\oplus \kappa_2}\oplus\dots\oplus (R/m^n)^{\oplus \kappa_n}$$ for cardinals $\kappa_1,\dots,\kappa_n$, where $n$ is minimal such that $m^n=0$.  Now note that $\operatorname{Hom}(R/m^i,R)\cong m^{n-i}R\cong R/m^i$, so if $Z=R^{\oplus\mu}$ then $$\operatorname{Hom}(X,Z)\cong( (R/m)^{\oplus \mu})^{\kappa_1}\oplus ((R/m^2)^{\oplus \mu})^{\kappa_2}\oplus\dots\oplus ((R/m^n)^{\oplus\mu})^{\kappa_n}.$$  When $\mu\geq|R|$, $((R/m^i)^{\oplus\mu})^\kappa$ is isomorphic to $(R/m^i)^{\oplus \mu^\kappa}$ (proof sketch: an $R$-module $N$ is a direct sum of copies of $R/m^i$ iff $\{x\in N:mx=0\}=m^{i-1}N$, and this property is easy to verify for $((R/m^i)^{\oplus\mu})^\kappa$).  Thus if you know $\operatorname{Hom}(X,Z)$ up to isomorphism for all $Z$, then you know the cardinals $\mu^{\kappa_i}$ for all $\mu\geq|R|$.  As in the previous argument, this uniquely determines the cardinals $\kappa_i$, and so determines $X$ up to isomorphism.
