TITLE: Trying to find a left adjoint
QUESTION [5 upvotes]: Let $\mathsf{Idem}$ be the category of sets that come with an idempotent endomorphism, i.e. the objects are pairs $(A,e)$ where $A$ is a set and $e:A \to A$ is an idempotent. The morphisms $f:(A,e) \to (B,d)$ are morphisms $f: A \to B$ in $\mathsf{Set}$ such that $df = fe$. Let $U\colon \mathsf{Idem} \to \mathsf{Set}$ be the forgetful functor.
I would like to find a left adjoint $F$ for this functor. I tried the functor $F$ where $F (A) = (A , 1_A)$ on objects, and $F( f\colon A \to B ) = f: (A, 1_A) \to (B, 1_B)$, on morphisms, but I can see no isomorphism $$\mathsf{Idem} ((A,1_A), (B,e)) \cong \mathsf{Set}(A,B).$$ I initially thought to send a map $f\colon (A,1_A) \to (B,e)$ to $ef\colon A \to B$, and a map $g\colon A\to B$ to $g\colon (A, 1_A) \to (B, 1_B)$ but this doesn't seem to be right. 
Does anyone have any advice about how to find such a left adjoint? I am not sure how to spot one. It seems that the functor has to incorporate some information about all the idempotents because we need $$\mathsf{Idem} \left( FA, (B,e) \right) \cong \mathsf{Idem} \left( FA, (B,e') \right) \cong \mathsf{Set}(A,B),$$
if $e, e'$ are two different idempotents. Any help would be appreciated.

REPLY [6 votes]: Let $F(A)=A\times\{0,1\}$, with $p:F(A)\to F(A)$ given by $p((x,t))=(x,0)$ (for any $x\in A$, $t\in\{0,1\}$). If $B$ is a set with an idempotent map $e:B\to B$ then any map $g:A\to B$ gives us $g':F(A)\to B$, defined by $g'(x,1)=g(x)$, $g'(x,0)=e(g(x))$, which makes $F$ left adjoint to $U$.