Hi Jean,
Developing some general tools for doing this sort of labelling is high on our list, but so far no one has tackled it. In the meantime there are various levels of doing it manually. Note your example is especially tricky because you are using primitive text objects, for which we cannot know the size. So for now let's assume that all the edge labels have about the same size.
First, we can do a little better by putting the labels near the actual midpoint of the edges instead of at the centroid of their endpoints (for curved edges the centroid can be quite far from the edge). To do this, simply replace "centroid [p1,p2]" by something like "head (pathTrails p) `atParam` 0.5".
Next, perhaps we don't want the labels right on top of the edges, but want to move them off to the side a bit. The idea would be to find the normal vector at the edge midpoint, and move the label some distance along the normal. Replace "centroid [p1,p2]" with "labelPt p" where
labelPt p = ltr `atParam` 0.5 .+^ 20 *^ n
where
ltr = head (pathTrails p)
n = ltr `normalAtParam` 0.5
This is a bit better, but it does not take into account labels overlapping with other edges, etc, nor does it take into account that if the labels are not square, we may want to move them a different distance depending on the angle of the normal. And perhaps you want to sometimes negate the normal depending on the concavity of the edge, etc. etc. --- as you can see there are an infinite number of variations of varying difficulty. But in any case I hope this is enough to get you started!
-Brent