chris-martin / bricks

Bricks is a lazy functional language based on Nix.
https://hackage.haskell.org/package/bricks
6 stars 1 forks source link

Require unquoted strings in the left-hand dict of recursive dict bindings #15

Closed chris-martin closed 6 years ago

chris-martin commented 6 years ago

These need to be unquoted for the same reason that the left-hand side of a let binding needs to be unquoted - because these are pulled into scope as variables.

This simplifies the evaluation we can eliminate recursive dicts during the Expression to Term conversion by transforming rec { a = x; b = y; } into let a = x; b = y; in { inherit a b; } (and describing that transformation serves well to document the semantics of recursive dicts).

chris-martin commented 6 years ago

Dict is going to need to split into Dict and DictRec as they are now fundamentally different constructs.

chris-martin commented 6 years ago

No, this is too limiting. You should be able to mix "variables" and "non-variables" in a single dict.

rec {
  c = "y";
  d = c;
  "a b" = "x";
  "${c}" = "z";
}

It is slightly awkward to describe what happens here, as not all of the keys become available as variables. Conversion from Expression to Term will transform this example into something like

let
  c = "y";
  d = c;
in {
  c = c;
  d = d;
  "a b" = "x";
  "${c}" = "z";
}

Any key that's dynamic or isn't representable in unquoted form won't get included in the recursive fun.

So I think this is fine as-is.