TITLE: Monoids in Category Theory
QUESTION [8 upvotes]: I don't have a strong math background (engineering math) so I am at a bit of a disadvantage here but I have been trying to learn the broad strokes of Category Theory to help get a fuller picture of some of the Functional programming languages I use (Haskell, Scala, F#, etc.).
I am reading 'An Introduction to Category Theory' by Harold Simmons and ran into something in the first chapter regarding Monoids that leaves me a bit confused.
He states that a Monoid is a structure $(R, *, 1)$ where $R$ is a set, $*$ is a binary operation on $R$ and $1$ is an element of $R$ that functions as an identity element.  So far, so good.
He goes on to state that a monoid morphism between two monoids:
$$p: R \to S$$
is a function that respects the structure of the monoids.  He then explains that this means:
$$p(r*s) = p(r) * p(s),\quad\mathrm{and}\quad p(1) = 1$$
where $r$ and $s$ are elements of $R$.
The question I have is that this seems to make certain assumptions: specifically, that $R$ and $S$ are the same monoid.  I say this since $p(r)$ is a morphism from $R$ to $S$ and $*$ is defined for $R$, but not necessarily for $S$. 
Have I missed something here?

REPLY [4 votes]: Why not write this out in Haskell! The monoid type class is defined as
class Monoid m where
  mempty :: m          -- Simmons calls this `1`
  (<>) :: m -> m -> m  -- aka `*`. (Or `mappend`.)

If now the types R and S are monoids, i.e.
instance Monoid R where { ... }
instance Monoid S where { ... }

then a function p :: R -> S is a monoid morphism if p (a<>b) ≡ p a <> p b, and p mempty ≡ mempty. Or, with explicit type annotations,
p (a<>b :: R) :: S
    ≡ (p a :: S) <> (p b :: S)
p (mempty :: R) ≡ (mempty :: S)

Note that the instantiations of <> and mempty belong to different instances of the monoid methods: on the LHS, it's the Monoid R instance, on the RHS it's the Monoid S instance. (Haskell's HM type system infers this by itself, if you don't write out the type signatures explicitly.)