Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape ${ in strings when printing Nix expressions #1019

Merged
merged 5 commits into from
Jan 6, 2022
Merged

Escape ${ in strings when printing Nix expressions #1019

merged 5 commits into from
Jan 6, 2022

Conversation

soulomoon
Copy link
Collaborator

@soulomoon soulomoon commented Jan 4, 2022

Fix for #1000
Following the fix in NixOS/nix 4012

  • What is done:

    • stop escaping a single $ sign in double quoted string if not following by { when printing.
    • escape ${ to \${ in double quoted string when printing.
    • update the tests for this behavior.
    • refactor to drop the usage of show in printNix, and unify some double string escape behavior for prettyString and printNix
  • What is not working:

Using ViewPatterns, PatternSynonyms, OverloadedStrings to achieve a readable code
`escapeDoubleQuoteString` to escape nix double quoted string in both `prettyString` and `printNix`
@soulomoon
Copy link
Collaborator Author

soulomoon commented Jan 5, 2022

Then I have done a refactoring of escape :: Char -> [Char] because I saw the comment.
Since we need to identify two Char pattern, the work around making the code ugly.

There is a way to refactor the code into nicer version by doing explicit recursion using bidirectional pattern synonym.

The idea is coming from here

@Anton-Latukha
Copy link
Collaborator

Anton-Latukha commented Jan 6, 2022

Checking the code locally for now (upstream shenanigans are currently not allowed to make GHC 9.0 CI usable).

@Anton-Latukha
Copy link
Collaborator

Reviewed the code.

Works locally.

@Anton-Latukha Anton-Latukha merged commit a9436eb into haskell-nix:master Jan 6, 2022
@Anton-Latukha
Copy link
Collaborator

Thank you for this

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