unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.81k stars 272 forks source link

search for string constants within codebase #2413

Open ceedubs opened 3 years ago

ceedubs commented 3 years ago

Sorry if there is already an issue for this; I couldn't find one.

As people start writing services in Unison, a really common use-case is going to be "Okay I see a log message that says couldn't load message because.... Where in my code did this come from?"

Traditionally you'd use something grep-like for this, but because Unison codebases aren't stored as text, you can't do that.

minimum requirements

nice to have

ceedubs commented 3 years ago

The fact that there's not really a concept of "my code" vs "external library" in Unison might make this a bit tougher to make this fast. Maybe confining within a namespace or within dependents of X helps?

aryairani commented 3 years ago

Good idea. We don't have an index for this, but we could add one in a future iteration.

ceedubs commented 3 years ago

@aryairani are you referring to a SQLite index that will end up in the SQLite file? I wonder if a useful index into the strings would end up adding a fair amount of bloat to the repo. I wonder if this should instead be a local cache, though then it might be a pain to manage. Luckily not as much of a pain, since Unison terms are content-addressed.

aryairani commented 3 years ago

@ceedubs The SQLite file is a local cache. I'm not familiar with the performance characteristics of sqlite full-text search, but I suppose they're in here somewhere: https://www.sqlite.org/fts5.html

bbarker commented 5 months ago

I think limiting to a namespace should be an option, but i would also like the ability to search through all of a namespace's dependencies (sometimes a log message can come from a dependency, as I'm currently experiencing).

I'm not very familiar with the Unison codebase - would it be possible to outline an approach with some of the modules involved?

ChrisPenner commented 5 months ago

Hi @bbarker ! We'd love to have your help contributing to Unison! Glad you're here :D

Realistically though, I don't think I'd recommend this as a good first issue to tackle, though it may seem simple on the surface there are a lot of complicating factors behind the scenes on this one that make it more complex than it probably should be.

We have a few issues tagged as good first issues to tackle, though admittedly the list may be a bit stale, so it would still be good to check in with the team (probably on Discord) before jumping in on anything: https://github.com/unisonweb/unison/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22

Let us know if you have any questions on anything 😄