# String diagrams for duals with TikZ

I would like to reproduce with TikZ the following diagrams

It would be nice to have them rotated of 90 degrees (so to resemble cup and cap symbols). I have searched how to create arches, which however do not seem to suit my desired result: is there any simpler solution?

Does something like that suits you?

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary[decorations.markings]

\begin{document}
\begin{tikzpicture}[arr/.style={
postaction={decorate},
decoration={
markings,
mark=at position #1 with {\arrow{>}}}}]

\draw[arr=0.6] (0,0) -- (0,1) node[pos=0.6,right]{A};
\draw (0,1) to[out=90,in=90,looseness=2] (1,1);
\draw[arr=0.5] (1,1) -- (1,0)node[pos=0.4,right]{A};
\draw (1,0) to[out=-90,in=-90,looseness=2] (2,0);
\draw[arr=0.6] (2,0) -- (2,1)node[pos=0.6,right]{A};
\end{tikzpicture}
\end{document}


You can use arcs as well. For the general shape, something like

\draw (0,0) -- (0,1)  arc[start angle=180, delta angle=-180, radius=0.5]
-- (1,0)  arc[start angle=180, delta angle=180, radius=0.5]
-- (2,1);


Because the vertical lines are 1 apart, the radius of the arcs are 0.5. The start angle defines the "anchor" for the circle of which the arc is part. For both cases, the arc should start at the leftmost point of the circle, start angle=180. Because the first arc goes counter clock wise from 180 to zero, I set delta angle=-180. The second arc goes clock wise, so delta angle=180.

Various examples, where I took the arr style for the markings from SebGlav's answer, so credit to him for that.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.markings}
\tikzset{
arr/.style={
postaction={decorate},
decoration={
markings,
mark=at position #1 with {\arrow{>}}}}
}
\begin{document}
% just simple shape
\begin{tikzpicture}
\draw (0,0) -- (0,1)  arc[start angle=180, delta angle=-180, radius=0.5]
-- (1,0) arc[start angle=180, delta angle=180, radius=0.5]
-- (2,1);
\end{tikzpicture}

% same shape with arrows
% arrow positions found by trial and error
\begin{tikzpicture}[
arr/.style={
postaction={decorate},
decoration={
markings,
mark=at position 0.1 with {\arrow{>}},
mark=at position 0.5 with {\arrow{>}},
mark=at position 0.925 with {\arrow{>}}
}
}
]

\draw [arr] (0,0) -- (0,1)  arc[start angle=180, delta angle=-180, radius=0.5]
-- (1,0)  arc[start angle=180, delta angle=180, radius=0.5]
-- (2,1);
\end{tikzpicture}

% separate paths
\begin{tikzpicture}
% first the three straight lines
% saving some coordinates for use later
\draw [arr=0.5] (0,0) -- node[left] {$A$} (0,1) coordinate (m1);
\draw [arr=0.5] (1,1) -- node[left] {$A$} (1,0) coordinate (m2);
\draw [arr=0.5] (2,0) -- node[left] {$A$} (2,1);

% then the two arcs
\draw (m1) arc[start angle=180, delta angle=-180, radius=0.5]
(m2) arc[start angle=180, delta angle=180, radius=0.5];
\end{tikzpicture}

% single draw, but with edge (which actually makes separate paths)
% because of edge, coordinates have to be repeated
\begin{tikzpicture}
\draw (0,0)   edge[arr=0.5] node[left] {$A$} (0,1)
(0,1) arc[start angle=180, delta angle=-180, radius=0.5]
edge[arr=0.5] node[left] {$A$} (1,0)
(1,0) arc[start angle=180, delta angle=180, radius=0.5]
edge[arr=0.5] node[left] {$A$} (2,1);

\end{tikzpicture}
\end{document}