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

Fix quasiquote free variable interpolation #1091

Closed ners closed 8 months ago

ners commented 8 months ago

Before this PR, HNix provided an implementation for interpolating free variables as Nix expressions. This was not called correctly, because the types did not match: it looked for NExprLoc instead of NExpr.

This PR fixes interpolation such that the following code works as expected:

let foo = "foo" :: String
[nix|
{
  foo = foo;
}
|]

produces:

{
  foo = "foo";
}

To do this, we fix the ToExpr typeclass to generate NExpr. We also provide some additional instances.

The diff also includes some lines that have been reformatted when running Brittany on the source file.

Anton-Latukha commented 8 months ago

Thank you for fixing it.