unisonweb / unison

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

`view` and `names` of a hash could distinguish between definitions that are unknown vs unnamed #1384

Open aryairani opened 4 years ago

aryairani commented 4 years ago

Current behavior:

scratch/main> view ##Nat

  ⚠️

  The following names were not found in the codebase. Check your spelling.
    ##Nat

scratch/main> names ##Nat

  😶

  I couldn't find anything by that name.

scratch/main> alias.type ##Nat Nat

  Done.

scratch/main> names ##Nat

  Type
  Hash:  ##Nat
  Names: Nat

scratch/main> view ##Nat

  -- Nat is built-in.

Desired behavior would be something like:

scratch/main> view ##Nat

  -- ##Nat is built-in.

scratch/main> names ##Nat

  There are no names for ##Nat in this branch.

scratch/main> view ##Cat

  This version of UCM doesn't provide a built-in called ##Cat.

scratch/main> names ##Cat

  There are no names for ##Cat in this branch.
  (And this version of UCM doesn't provide a built-in called ##Cat.)

scratch/main> names ##Rat

  Type
  Hash:  ##Rat
  Names: Rat
  (Although this branch has a name for it, this version of UCM doesn't provide a built-in called ##Rat.)

scratch/main> names #00nv2kob8f

  There are no names for ##00nv2kob8f in this branch, but it is named in the following branches:

  Branch                        Name
  @unison/base/main  Unit

or

scratch/main> names #00nv2kob8f

  There are no names for ##00nv2kob8f in this branch, but here's the definition:

  structural type #00nv2kob8f = #00nv2kob8f#0

nice-walrus/main> view #00nv2kob8f Cat #00nv2kob8e

  structural type #00nv2kob8f = #00nv2kob8f#0

  ⚠️

  The following names don't exist in this branch:
    Cat

  The following hashes don't exist in this codebase:
    #00nv2kob8e
venus-as-a-boy commented 3 years ago

I'm going to try and take a crack at this.

pchiusano commented 3 years ago

@TheAceShinigami Great!

emilhotkowski commented 2 years ago

It was a year since last comment. Is it still relevant? And could I pick this up if so?

aryairani commented 3 weeks ago

Still relevant, feel free! I updated the "desired behavior" section. I gave some options that are easier than others, it's open to negotiation.