-
Couldn't load subscription status.
- Fork 364
chat: improve namespacing of chat-* types #2814
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
Conversation
Improved the namespacing by dropping the app prefix on types, e.g.
chat-hook-action -> action. Compensated for shadowing by importing the
/sur files behind a face. End result is that a chat-hook-action becomes
an action:hook. Splits chat-json into lib/chat-{hook,store,view}. Uses
^? on changes files in /lib and /sur to discourage deeply nested
importing.
|
(Informal GitHub etiquette: only tag reviewers if they're required; cc optional reviews. This isn't codified yet iirc, but it helps clarify when merging.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Righteous! These are good conventions and these changes have been well-executed.
pkg/arvo/mar/chat/view-action.hoon
Outdated
| ++ json | ||
| |= jon=^json | ||
| (json-to-view-action jon) | ||
| (action:dejs jon) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just put ++ json action:dejs
pkg/arvo/mar/chat/hook-action.hoon
Outdated
| ++ json | ||
| |= jon=^json | ||
| (json-to-hook-action jon) | ||
| (action:dejs jon) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can replace with ++ json action:dejs
pkg/arvo/mar/chat/action.hoon
Outdated
| ++ json | ||
| |= jon=^json | ||
| (json-to-action jon) | ||
| (action:dejs jon) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I neglected to mention in conversation, @liam-fitzgerald, is that maybe lib and sur files for the stores themselves shouldn't have the -store suffix. Idea here being that the things in them are data structures and associated helpers for the entire suite of apps, not just the store.
So you'd get, for example, envelope:chat and action:chat in /sur/chat.hoon.
Wondering what you think of this. It does rub up against "1 file per app" a little bit, in that the relation is less literal.
Left some more comments below, but changes look good otherwise! Happy to see this done. (:
pkg/arvo/app/chat-store.hoon
Outdated
| :: chat-store: data store that holds linear sequences of chat messages | ||
| :: | ||
| /+ *chat-json, *chat-eval, default-agent, verb, dbug | ||
| /- store=chat-store |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed importing "native" types (and maybe libs) with *, and thought we agreed on that? Having :store suffixes, inside of the store, feels a little bit silly to me. (Same goes for the other apps.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been flipping back and forth on this. I like having :store suffixes because
- using the autoname syntax doesn't shadow the type.
- It preserves a semblance of referential transparency inside the chat context. It's not uncommon to have to make changes to both the -store and -hook and I think preserving the namebindings is useful to prevent unnecessary context switches
- Types aren't really that hard up for space in most common syntactical situations, so identifier length is not really an issue here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Each file can get one sur * or one lib *, after that things get too confusing" seems like a reasonable compromise. Otoh -lib suffixes appearing anywhere are a sign that something has gone obviously wrong, and imo a fairly strong argument for a "stacking" model of "a library will frequently subsume the structure by the same name, pull in only one of them" - I don't believe e.g. inbox-to-configs:store would be overly unclear compared to inbox-to-configs:store-lib.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having libs and matching surs under the same namespace sounds pretty nice, yeah. Lacking support for simultaneous /- name=thing and /+ name=thing, doesn't seem too unreasonable to just expose the types with the lib, under the assumption you're gonna need them anyway.
I kinda dislike this, because it implies (at least to me) that |
|
Personally I would push for the ^? being part of the ford /- * syntax, so you can still structure things as multiple cores but have to be explicit about things. It's not being able to get at things at all that's an issue, it's them being spilled into a uniform namespace: if you see action:chat-sur:chat-lib due to both being qualified imports, you can follow that something funky is going on. |
| ++ grab | ||
| |% | ||
| ++ noun chat-hook-update | ||
| ++ noun update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something I don't love here is these are in fact being sent over the wire as %chat-hook-update, which might warrant some verbosity in at least the marks and !<s for consistency. (Alternately the mark system should perhaps have some manner of namespacing… even like, %chat-hook--update would make intermittent usage of the bare name less awkward)
pkg/arvo/lib/chat-view.hoon
Outdated
| /- *chat-view, *rw-security | ||
| |% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, but with the ^? removed, this would still expose the *rw-security. Wondering if there's some middle ground here where we can selectively expose only the types (core) "native" to the lib...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we just cons the sur import and the library core together? and then ^? the result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, that seems to work.
You're gonna have to =, chat-view instead of importing as *chat-view though, which is bad-style use of =,. I guess the ends justify the means here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, this seems good! (:
pkg/arvo/lib/chat-store.hoon
Outdated
| %text | ||
| (frond %text s+text.letter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| %text | |
| (frond %text s+text.letter) | |
| %text | |
| (frond %text s+text.letter) |
The backsteps on these are still a bit too aggressive.
|
Liam the indenting you “fixed” is wrong... it was right before |
1ec3caa to
1faf359
Compare
|
Pls approve @loganallenc @Fang- |
|
Morge |
|
You have a merge conflict here @liam-fitzgerald |
pkg/arvo/lib/chat-store.hoon
Outdated
| ++ letter | ||
| |= =^letter | ||
| ^- json | ||
| =, enjs:format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh right the tiscom
pkg/arvo/lib/chat-store.hoon
Outdated
| ++ config | ||
| |= =^config | ||
| ^- json | ||
| =, enjs:format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary
|
This has a merge conflict again. When should this even be merged? And what target? It seems like these can go out whenever; they're more for developer benefit than user fixing. |
afaic this can be merged when conflict is resolved, onto a |
|
ping @liam-fitzgerald Mind fixing the conflicts and targeting |
|
Don’t merge yet I have to port the virtualisation changes |
|
RIP sorry You can make another PR for |
Namespacing proposal:
actionneverchat-hook-actionaction:sur:chat-hook-lib)Implements the above proposal for the chat-* apps.
If everyone's happy with this, I'd like to extends this style to the rest of the codebase