Show that $Hom_R(R^n,M) \cong M^n$ for R-modules

We want to show that $Hom_R(R^n,M) \cong M^n$ for $n\in\Bbb Z_{\ge0}$

I have already shown that $Hom_R(R,M) \cong M$ by letting $f:Hom_R(R,M)\rightarrow M$ given by $f(\phi) = \phi(1)$.

I showed that $f$ is bijective and is a group homomorphism, thus $Hom_R(R,M) \cong M$.

It seems too easy to define the same function for $Hom_R(R^n,M) \cong M^n$, I must be doing something wrong. Injectivity and surjectivity were both straightforward, and showing its a homomorphism seemed to go okay… Can you just use the same $f$? How can you show these are isomorphic?

Solutions Collecting From Web of "Show that $Hom_R(R^n,M) \cong M^n$ for R-modules"

In general, following theorem holds:
$$\operatorname{Hom}_R\left(\bigoplus_{i\in I}A_i, B \right)\cong \prod_{i\in I}\operatorname{Hom}_R(A_i,B)$$

Let define a map $\phi$ from the former to the latter defined as
$$\phi(f) := \langle f\circ \iota_i\rangle_{i\in I}$$
(where $\iota_i:A_i\to \bigoplus_{i\in I} A_i$ be the canonical insertion) and define map $\psi$ from the latter to the former as
$$\psi(\langle g_i\rangle_{i\in I})(a) = \sum_{i\in I}g_i(a_i).$$
Above sum ranges for all $i\in I$. Each $g_i$ is a morphism from $A_i$ to $B$ and $a = \langle a_i\rangle_{i\in I} \in \bigoplus_{i \in I} A_i$. $a_i=0$ but finitely many so $\psi(\langle g_i\rangle_{i\in I})$ is well-defined. You can check that $\phi$ and $\psi$ are homomorphism and inverses each other.

You can find the finite version of above theorem, and its proof is essentially same.