Multi-line string support with stripped indentation
I would like to switch from neat-interpolation because string-interpolate is better in every way. The only reason I haven't is because I need support for multi-line strings where the indentation (and leading and trailing newlines) are stripped.
My program uses a lot of multi-line strings for human-consumed error messages. Currently they are written like this with neat-interpolation:
someMessage :: Text
someMessage =
[trimming|
This is an example error message.
Some key: Some value
Another key: Another value
This will be posted in something like a GitHub comment or email, where I value using multiple lines and padding.
|]
With string-interpolate, I would have to write them like this to ensure I don't have any extra whitespace:
someMessage :: Text
someMessage =
[i|This is an example error message.
Some key: Some value
Another key: Another value
This will be posted in something like a GitHub comment or email, where I value using multiple lines and padding.|]
This gets even uglier and harder to read when the quasiquoter starts more indented (e.g. inside a where clause) because I'm forced to start new lines without any indentation. I also can't use the iii quasiquoter because then I would lose my newlines and padding.
Would you consider adding back the __i quasiquoter? I see that you decided against adding it in this PR: !21 (merged). But I feel like this is one of the most common use cases for these multi-line string interpolation libraries.
I think the most intuitive behavior for a __i quasiquoter would be:
- Strip leading and trailing newlines (anything bumping up against
[i|and|]) - Strip leading indentation, using the least indented line as column 0
Basically what neat-interpolation is already doing with its trimming quasiquoter.