Improve Unison's `find`: Skip Transitive Dependents For Faster Searches

by Sebastian Müller 72 views

Hey everyone,

Let's dive into a crucial discussion about improving the find command in Unison. Currently, when you use find to search for something like test.verify, the results can be overwhelming. You end up with a ton of matches buried deep within the versions of base libraries in your transitive dependencies. It's like searching for a needle in a haystack, right?

The Problem with find and Transitive Dependencies

So, you know how it goes. You're trying to find a specific function or test, and you run find test.verify. Instead of getting a clear and concise result, you're bombarded with matches from various versions of unison_base that are dependencies of your dependencies. Check out this example:

arcella/page> find test.verify

  0102
  I couldn't find matches in this namespace, searching in 'lib'...


  1.  lib.ceedubs_exists_1_6_0.lib.unison_base_3_13_0.test.verify : '{g,
                                                                    Exception,
                                                                    Each,
                                                                    Random,
                                                                    Label} ()
                                                                    ->{g} [Result]
  2.  lib.orderator_0_10_0.lib.unison_base_3_32_0.test.verify : '{g,
                                                                Exception,
                                                                Each,
                                                                Random,
                                                                Label} ()
                                                                ->{g} [Result]
  3.  lib.unison_cloud_20_15_0.lib.unison_http_3_6_0.lib.systemfw_concurrent_2_2_0.lib.unison_base_3_7_0.test.verify : '{g,
                                                                                                                       Exception,
                                                                                                                       Each,
                                                                                                                       Random,
                                                                                                                       Label} ()
                                                                                                                       ->{g} [Result]
  4.  lib.ceedubs_exists_1_6_0.lib.unison_base_3_13_0.test.verify.doc : Doc
  5.  lib.ceedubs_exists_1_6_0.lib.unison_base_3_13_0.test.verifyWithSeed : Nat
                                                                            -> '{g,
                                                                            Exception,
                                                                            Each,
                                                                            Random,
                                                                            Label} ()
                                                                            ->{g} [Result]
  6.  lib.ceedubs_exists_1_6_0.lib.unison_base_3_13_0.test.verifyWithSeed.doc : Doc
  7.  lib.orderator_0_10_0.lib.unison_base_3_32_0.test.verify.doc : Doc
  8.  lib.orderator_0_10_0.lib.unison_base_3_32_0.test.verifyWithSeed : Nat
                                                                        -> '{g,
                                                                        Exception,
                                                                        Each,
                                                                        Random,
                                                                        Label} ()
                                                                        ->{g} [Result]
  9.  lib.orderator_0_10_0.lib.unison_base_3_32_0.test.verifyWithSeed.doc : Doc
  10. lib.unison_base_4_2_0.test.verify.doc : Doc
  11. lib.unison_base_4_2_0.test.verifyWithSeed.doc : Doc
  12. lib.unison_cloud_20_15_0.lib.unison_base_4_0_0.test.verify.doc : Doc
  13. lib.unison_cloud_20_15_0.lib.unison_http_3_6_0.lib.systemfw_concurrent_2_2_0.lib.unison_base_3_7_0.test.verify.doc : Doc
  14. lib.unison_cloud_20_15_0.lib.unison_http_3_6_0.lib.systemfw_concurrent_2_2_0.lib.unison_base_3_7_0.test.verifyWithSeed : Nat
                                                                                                                               -> '{g,
                                                                                                                               Exception,
                                                                                                                               Each,
                                                                                                                               Random,
                                                                                                                               Label} ()
                                                                                                                               ->{g} [Result]
  15. lib.unison_cloud_20_15_0.lib.unison_http_3_6_0.lib.systemfw_concurrent_2_2_0.lib.unison_base_3_7_0.test.verifyWithSeed.doc : Doc

Gak! That's a lot of noise, right? You're wading through results from lib.ceedubs_exists_1_6_0, lib.orderator_0_10_0, and even deeper dependencies like lib.unison_cloud_20_15_0.lib.unison_http_3_6_0.lib.systemfw_concurrent_2_2_0.lib.unison_base_3_7_0. It's just too much to sift through.

Why This Matters

This issue makes it harder to quickly find what you're looking for. When you're debugging or exploring code, you want the find command to be your friend, not your foe. A cluttered output slows you down and makes the development process less efficient. We want the find command to return results from the current namespace first, and only search transitive dependencies if there are no matches in the current namespace. This will help to reduce the noise and make it easier to find what you are looking for.

The Proposed Solution: Skip Transitive Dependents by Default

The solution is pretty straightforward: make find skip transitive dependents by default. Think of it as a