infinisil changed the topic of #nix-lang to: Channel for discussing Nix as a language - https://nixos.org/nix/manual/#chap-writing-nix-expressions - Logs: https://logs.nix.samueldr.com/nix-lang/
<elvishjerricco> Is there anything preventing the addition of a let binding syntax like this? `let { config, options } = evalModules ...;`
pie__ has joined #nix-lang
pie__ has quit [Ping timeout: 252 seconds]
MichaelRaskin has quit [Quit: MichaelRaskin]
pie_ has joined #nix-lang
pie__ has joined #nix-lang
pie_ has quit [Ping timeout: 272 seconds]
<infinisil> elvishjerricco: there kinda is already
<elvishjerricco> infinisil: Yea, I guess `let inherit` covers that reasonably well
<infinisil> Yeah
<ekleog> what is `let inherit`?
* ekleog hopes for a new toy
<srhb> ekleog: Exactly what you'd think.. let inherit (pkgs) hello; in hello
<ekleog> > let inherit ({ a = 1; }) a; in a
<{^_^}> 1
<ekleog> oh nice :)
<ekleog> so now we only need `let inherit (foo) *; to be able to do really crazy stuff :3
<ekleog> (remember your lisp needing to define the variables, infinisil? :p)
<infinisil> ekleog: inherit (...) * would be really nasty and probably require ugly nix changes
<ekleog> yeah I totally agree
<infinisil> Well, it's just `with` actually
<infinisil> And I'm using `with` for nixlisp already :)
<ekleog> oh wait yeah
<infinisil> (Except with can't define certain things)
<ekleog> > with (builtins.listToAttrs (map (a: { name = a; value = {}; }) (builtins.genList (a: builtins.substring a 1 "abcdefghijklmnopqrstuvwxyz") 26))); b
<{^_^}> 10
<ekleog> wtf
<ekleog> why isn't it giving {} like locally? o.O
<infinisil> > b
<{^_^}> 10
<infinisil> ^^ Defined with a let in
<ekleog> oh
<ekleog> so it isn't overrided by the current expression? oO
<infinisil> The nix repl I shortly worked on at Nixcon will fix this
<infinisil> (I call it nix-session, not yet finished)
<ekleog> oh there's no builtins.mod?
<infinisil> Unfortunately not :P
<infinisil> Wouldn't mind having that
<ekleog> got it :D
<ekleog> > let chr = x: builtins.substring x 1 "abcdefghijklmnopqrstuvwxyz"; chrL = 26; chrs = x: let next = builtins.div x chrL; in if x < chrL then chr x else chr (x - next * chrL) + chrs next; attrs = builtins.listToAttrs (map (a: { name = a; value = {}; }) (builtins.genList chrs (chrL * chrL))); in with attrs; yr
<{^_^}> { }
<ekleog> and then just use chrL * chrL * chrL for 3-char idents :3
<infinisil> What's that do?
<ekleog> generates all identifiers of 1 or 2 letters and attribute them the value `{}`
<ekleog> (as defined in the `value = {};`
<infinisil> Ahhh
<ekleog> )
<ekleog> now you just need to define them as nixlist-vars :P
<ekleog> nixlisp*
<ekleog> it's getting slow at chrL ** 4 locally
<infinisil> > pow 26 4
<{^_^}> 456976
<ekleog> not going to try ** 5 :p
<infinisil> Not very practical unfortunately
<ekleog> seems like most of the time is spent generating the list, so it's a 1-time ~1s use
<ekleog> (using `zrae` and `zrae//aebr` takes approx. as long)
<ekleog> to do better nix would need to support lazy identifiers :/
<ekleog> (also, am I the only one thinking this?)
<ekleog> I think I'm falling in love with __functor's possible use cases here https://discourse.nixos.org/t/syntax-for-proposed-extensible-attrset/1337/6
* ekleog wonders whether he should poke #nixos-dev / some issue tracker somewhere about this
<ekleog> if someone points me to somewhere I should add more details about it, I may even find motivation to write the `__functor` function necessary to support an almost-library-only implementation of extensible attrsets :D
<ekleog> nvm, found the gist again :)
<ekleog> ugh “Gist doesn't send out notifications for replies, nor for explicit mentions” <- so it's useless to reply there…
<infinisil> ekleog: I guess what you want is this:
<infinisil> > fun = self: rec { __overrides = self; a = 1; b = a; }
<infinisil> > fun = self: rec { __overrides = self; a = 1; b = a; }
<{^_^}> fun defined
<infinisil> > deepEval (fun {})
<{^_^}> { __overrides = { }; a = 1; b = 1; }
<infinisil> > deepEval (fun { a = 2; })
<{^_^}> { __overrides = { a = 2; }; a = 2; b = 2; }
<ekleog> infinisil: what is that __overrides? o.O
<infinisil> Secret Nix magic :P
<ekleog> but… but…
<ekleog> why do people even say we need a language extension for extensible attrsets? x)
<infinisil> Because __overrides is ugly, and I'm pretty sure it can't handle the types and merges
<ekleog> this can be handled in __functor
<ekleog> hmm wait __overrides works only with the variables defined at the same time, right?
<infinisil> You sure?
<infinisil> Yeah
<ekleog> so it won't be possible to use it from __functor actually
<ekleog> yeah, my idea was to just do the evaluation of late-bound variables in __functor
<ekleog> but here… actually I'm not sure
<ekleog> guess I need to sleep on this and see what tomorrow thinks about it :)
<infinisil> ekleog: I think the main point is to have language level support for modules
<infinisil> So it's efficient
<ekleog> is it really going to be more efficient?
<ekleog> I mean, it's still going to call into nix code for typechecking
<ekleog> and it's going to hardcode *lots* of stuff :(
* ekleog would really just want the metadata association syntax for sets and functions
<ekleog> (well, and late-bound sets if they're really needed)
<ekleog> and them if there's an optimize-able bottleneck a builtin could be introduced to make it faster, but I don't see much from a not-yet-implemented perspective
qyliss^work has joined #nix-lang
pie__ is now known as pie_
MichaelRaskin has joined #nix-lang
<elvishjerricco> Wait what is that `__overrides` thing?
<gchristensen> a bad thing which shouldbe/willbe deleted from nix
<infinisil> elvishjerricco: It allows changing the variables a rec brings in scope
<infinisil> And this `self: rec { __overrides = self; ... }` combo is a bit special
<infinisil> `self: rec { __overrides = self; a = 1; b = a; }` is the same as `self: { a = 1; b = self.a; }` I'm pretty sure
<infinisil> So it provides a way to have `rec { ... }` like behavior (not having to use self. for everything), but still be able to override stuff with self through a fixed point