I'm reading Goldblatt's: Topoi. Here:
An arrow $f:a \to b$ in a category $\mathscr{C}$ is monic in $\mathscr{C}$ if for any parallel pair $g,h:c\rightrightarrows a$ of $\mathscr{C}$-arrows, the equality $f\circ g=f\circ h$ implies that $g=h$. The symbolism $f:a\rightarrowtail b$ is used to indicate that $f$ is monic. The name comes from the fact that an injective algebraic homomorphism (i.e. an arrow in a category like $\mathbf{Mon}$ or $\mathbf{Grp}$) is called a "monomorphism".
I got curious: Is there any situation in which $f\circ g=f\circ h$ does not imply $g=h$? My guess is that for it to imply that, we need:
$$f\circ g =f\circ h$$
$$(F\circ f)\circ g =(F\circ f)\circ h$$
$$Id_B \circ g =Id_B \circ h$$
$$ g = h$$
So I guess that the situation I'm looking for is whenever we don't have an arrow $F$ such that $F\circ f=Id_B$. Is that correct?
If there exists a left inverse $F$ of $f$, then clearly $f\circ g = f \circ h$ implies $g = h$. So the absence of a left inverse is necessary for the implication to fail. It is however not sufficient, here's a counterexample:
Consider the one-object category whose morphisms form a free monoid. Only the identity morphism has a left inverse, yet every single morphism is monic. This is because free monoids are left cancellative.