Skip to content

Conversation

@georgefst
Copy link
Contributor

This appends two located trails by adding a new segment from the end of the first to the start of the second. Come to think of it, that's potentially non-obvious and is probably worth a Haddock comment.

We could maybe avoid a new segment if the start and end align precisely, though in practice this means floating-point equality checks. I don't know if Diagrams does something like that elsewhere, e.g. for gluing lines in to loops? Or whether it checks within some tolerance?

Even ignoring that, there's no valid Monoid instance because the location for the empty line would be dependent on the start or end position of the line it's being concatenated to.

@byorgey
Copy link
Member

byorgey commented Nov 4, 2025

This makes sense! And yes, it's definitely worth adding a Haddock comment.

I don't want to mess with conditionally omitting the joining segment. That sounds fragile and icky. Gluing a line into a loop just changes the endpoint of the last segment to be the same as the start, it does not do anything conditional. We could add a note to the Haddock comment to the effect that if you have two located trails where the start of the second coincides with the end of the first, you might be better off with something like mapLoc (<> unLoc t2) t1.

@byorgey
Copy link
Member

byorgey commented Nov 18, 2025

@georgefst did you want to push up another commit to this branch adding a Haddock comment? I can also do it if you don't have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants