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

Referential opacity exposed by the module system #217

Closed
shlevy opened this issue Feb 27, 2014 · 0 comments
Closed

Referential opacity exposed by the module system #217

shlevy opened this issue Feb 27, 2014 · 0 comments

Comments

@shlevy
Copy link
Member

shlevy commented Feb 27, 2014

$ cat module.nix 
let
  lib = import <nixpkgs/lib>;
  eval = (lib.evalModules {
    modules = [ ({ options, lib, ... }:
      let
        tr1 = builtins.trace (builtins.typeOf options) null;
        tr2 = builtins.trace (builtins.typeOf options) null;
      in lib.seq tr1 {
        options = {
          foo = lib.seq tr2 {};
        };
      }
    ) ];
  }).options.foo;
in builtins.trace ''
  nix version is ${builtins.nixVersion}
  nixpkgs version is ${lib.nixpkgsVersion}'' (lib.seq eval {})
$ nix-instantiate module.nix 
trace: nix version is 1.7pre3488_36b90e7
nixpkgs version is 14.02pre39778.d5211b0
trace: lambda
trace: set

Note that the last two traces should be identical.

@edolstra edolstra self-assigned this Feb 27, 2014
zolodev pushed a commit to zolodev/nix that referenced this issue Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants