Skip to content

Introduce matched_string#34

Merged
EmileTrotignon merged 1 commit into
Drup:masterfrom
EmileTrotignon:matched_string
Nov 21, 2025
Merged

Introduce matched_string#34
EmileTrotignon merged 1 commit into
Drup:masterfrom
EmileTrotignon:matched_string

Conversation

@EmileTrotignon
Copy link
Copy Markdown
Collaborator

val matched_string: (_, 'a) t -> string pattern

This takes any regexp, discards the value, and returns the string matched by the pattern.

I first made a version where evaluability was preserved, but it did not work with prefix or suffix, as they destroy information about the value that is still visible in the matched string.

Maybe there is way around that where matched_string changes the behaviour of the prefix and suffix it contains, but I don't really see a way to type this.

Code for that can be found here, including the failing test.

The diff is very large because this is based on #33 , so its better to read the second commit.

I also noticed a that the types for prefix and suffix where wrong, this prevented me from writing the test I wanted to so I fixed it. There might be other case where this is an issue, I am not sure what the solution is given I have to to give the type expression to some things because of the value restriction (this is an false positive from the value restriction because the type is actually phantom, but can we show that to the compiler ?)

@EmileTrotignon EmileTrotignon merged commit e15bad3 into Drup:master Nov 21, 2025
4 checks passed
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.

1 participant