haskell-nix / hnix

A Haskell re-implementation of the Nix expression language
https://hackage.haskell.org/package/hnix
BSD 3-Clause "New" or "Revised" License
741 stars 114 forks source link

Escape ${ in strings when printing Nix expressions #1019

Closed soulomoon closed 2 years ago

soulomoon commented 2 years ago

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

soulomoon commented 2 years ago

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 commented 2 years ago

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

Anton-Latukha commented 2 years ago

Reviewed the code.

Works locally.

Anton-Latukha commented 2 years ago

Thank you for this