Allow a prefix for ?? placeholders #1018
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before submitting your PR, check that you've:
@since
declarations to the HaddockAfter submitting your PR:
OK, so this is going to be trickier than it should be. The code that actually does the name prefixing is here:
So we arrive at
name
from theentityDef
, and then we immediately collapse that information into a concatenated string. We don't have a good hook to intercept this.A possible solution is a
newtype
:This would require the user to write:
I'm not super pleased with this, but it's a drop-in solution that doesn't require modifying any existing code.
Another option is to parse the column substitutions returned from this and re-splice the desired prefix. Kind of gross, but it should work seamlessly -
replace (escape entityName) (escape desiredPrefix) columnSubstitutions
. How do we get the desired name, though?Currently, the implementation splits on
??
, performs substitution, and then rejoins:If we take
T.uncons
on the text, and that is a.
, then we should be able to dig out the previous few characters from it and pick that as the desired name. This will need to respect escaping etc so it's not going to be trivial to write the code to capture it. But a good first pass can merely require that it's an "easy" identifier.This is a bit nasty, but it's not a breaking change and doesn't require any newtype wrangling.
Fixes #1017