-
Notifications
You must be signed in to change notification settings - Fork 113
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
Can NixString be the NAtom? #534
Comments
To put my words more direcly: String is an NAtom type in Nix language. In Nix language, there is no such type as char (manual). And string can not be assembled from list of chars, only from other strings. The |
So do you propose adding |
Once more.
The source description of the initial author also belabors it:
It is Nix-native atomic types, they are as they are in AST and evaluate to themselves, at least the Strings evaluate into themselves. I also had a pretty good nod from the type system that it should be in there. |
Actually great: f682907 |
+==== As we know there were For me it is interesting what data type version should be in NAtom:
Only when they are both combined - there is a meaning in the expression. The context bears rules How to apply the expression properly. As some physicians say - physics explains "How" (how it, world behaves), it does not concerned with "Why" until it collides with physics. Question How is perpendicular to Why. If we talk to an alien - we would not understand each other right away, because we do not know the context, we do not know How to share information between. Richard Feynman was also famous for his explanations that meaning&context is a dao thing. He shows that simple "Why?" always changes and expands the context. And in the end where is no context we can grasp - you can never explain "Why?". He often said that his father taught him: "Let us think/look at this like Martians (or mushrooms)", he used this method of thinking to find other ways of context&meaning to see other sides of the question, quite like in discussion everybody has a somewhat different context to share. But he had a contrary, perpendicular goal.
That is why any expression or language bear context. And Nix had one basic type for both Expression and String, and context of it.
Then Nix can manage anything literally, even the Expression that has String with literal Nix expressions inside of it (comment with code samples) - so it can for Nix be both String and Expression, depending on the context said to the interpreter. So for example we can be explained by context to the interpreter - for example the whole Nixpkgs to be treated as NAtom - do not try to interpret any of it at any situation - just move it/clone it somewhere. And that is a basic instruction to the interpreter. The type and what single action to do - that is why Expr/NString is inside NAtom. When/if Nixpkgs splits into Flakes - we see that those NAtom abilities become essential to move Flakes, compose them around. Or if we do any actions with any two expressions, deliver some expression into the main expression - we see how is that smaller one should be the NAtom in AST for the interpreter - so interpreter would move the NAtom around and properly put it inside the main expression. And then/when context changes - & the interpreter allowed to evaluate it - it from NAtom becomes the readable expression to the interpreter, and so it is together composed. I now do not properly remember where I remember it from, so many scattered Nix materials. I've read it somewhere in the past, maybe even NixPills. I also remember seeing/reading the basic types in Nix source code. I definitely remember there were 6 of the basic types and that String preserved context. |
I am on sides of it. It seems logical. But the other type also looks so simple, and without context. I think we need not invent own stuff - because we would get headbumps and some processing details changes that would resolve in some discrepancies while we stay try to preserve proper Nix lang to evaluate Nixpkgs and bisimulate Nix. It just trying juggle too much. I also think we should really bisimulate the type system of Nix first - then it is a way easier to rely on that to bisimulate the existing language and its meaning on top of it. If something - we always would be able to read the code how it is made. |
Looking at the code it's now clear to me what you've meant but I'm not really sure which approach is better. Regarding For the reference I'll add http://blog.shealevy.com/2018/08/05/understanding-nix's-string-context/ by @shlevy who also authored the current string context handling. |
In NAtom Strings OR Expressions should be represented, basically, any Strings are also Expressions, they are really they are the same thing, in Nix moreover. |
Closing in favour of more gradual approach to the question: #657 |
Upon progressing with #509, in the current issue, I am wrestling with existential higher-rank type inference. And everything came into the one type level puzzle piece:
Expected NAtom, actual type NixString
.And I thought why not both? It seems like it should be so.
It seems like Nix-native
NixString
({Text, Hash}
) indeed can be represented with anNAtom
since it is a literal pun, and one of the Nix basic types.In
Strings.hs
there isextract
&create
&modify
and such:hnix/src/Nix/String.hs
Lines 225 to 227 in 0305b52
hnix/src/Nix/String.hs
Lines 201 to 208 in 0305b52
And in
Atom.hs
everything seems welcoming it also:hnix/src/Nix/Atoms.hs
Lines 21 to 50 in 0305b52
At least that should help type system and me, simplify some type inference, and probably would allow to even better formalize the text & string functions.
Is this sane idea?
The text was updated successfully, but these errors were encountered: