unisonweb / unison

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

Bulk namespace editing #1995

Open pchiusano opened 3 years ago

pchiusano commented 3 years ago

Modifying a namespace via delete.term, rename.type, alias.term, and so on can get tedious. The idea here is to get the namespace into your text editor where you can do whatever regex munging you want to make a bunch of changes. You could also write scripts to do things like convert in bulk from camelCase to snake_case, or I was even thinking of converting identifiers from one language to another.

Idea came out of discussion with @rlmark who has hit some awkwardness with this.

.base> rename.bulk

  Added base.bulk file. Edit this file then do 

      rename.bulk base.bulk

  to perform a collection of deletes, renames, and aliases.
$ cat base.bulk

# This file lists all terms, types, and patches in the namespace
# Add a `d mydef` at the start of any definition `mydef` that you wish to delete
# Add a `a oldname newname` line for aliases you wish to add
# Add a `r oldname newname` line for renames
# Leave a line alone if you want to leave that name unchanged

# Types

Optional
List
Abort
Either
IO

# Terms

Optional.map
Optional.map.doc
pchiusano commented 3 years ago

Related: https://github.com/unisonweb/unison/issues/1526

runarorama commented 3 years ago

Issues in this vein are going to continue to accumulate until we have access to the codebase via Unison.

aryairani commented 3 years ago

@runarorama What would a solution look like if we had access to the codebase via Unison?

runarorama commented 3 years ago

You could write a Unison program to modify the namespace, rather than have a special syntax.

runarorama commented 3 years ago

Another similar issue is bulk-editing patches. You'll often want to clean up a patch and that's tedious to do manually.