Skip to content
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

Breadcrumb bar #1118

Open
wants to merge 100 commits into
base: dev
Choose a base branch
from
Open

Breadcrumb bar #1118

wants to merge 100 commits into from

Conversation

xzxzlala
Copy link
Contributor

@xzxzlala xzxzlala commented Oct 8, 2023

Breadcrumb bar of hazel.
Now merged the haz3l-module branch.
could show the current function/module you are in, and the droppings contains other same level functions/modules.
The level is decided by how many funs/modules you are in.
For example, below the cursor is in f1 and g3 and finally in M2:
@Q1Y9HR T$6V0UT`E}{F3UP

@disconcision
Copy link
Member

how about something like this?

Screenshot 2023-12-04 233516

(we should also just stick those icons in the nut menu)

let l2 =
List.concat(List.map(t1 => tag_term(snd(t1), level), t));
l1 @ l2;
| _ => []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, another annoying little detail!! For pattern matching over expressions like this we like to write out every case, instead of having a catch-all "_ => ..." so that if anyone else adds anything to the language, the compiler will force them to update this function.

let tagged = tag_term(term, 1);
let lst = combineList(tagged);
let ancestors = Info.ancestors_of(ci);
let rec filter_ancestors = (ancestors_lst: Info.ancestors, level: int) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, here's a couple tricks that might help:

  1. you can combine patterns when pattern matching
  2. you can add a "when" to pattern matches as well

so this whole thing could probably become just one pattern match with four cases

switch (Id.Map.find_opt(List.hd(ancestors_lst), info_map)) {
  | Some(Info.InfoExp({Fun(_), ancestors, _})) when List.length(ancestors) >= 1 => [ ... ]
  | ...

@cyrus-
Copy link
Member

cyrus- commented Dec 11, 2023

how about something like this?

Screenshot 2023-12-04 233516 (we should also just stick those icons in the nut menu)

yeah this looks good!

@cyrus-
Copy link
Member

cyrus- commented Dec 11, 2023

@xzxzlala I think we actually want to include let bindings of regular values, not just functions, in the list + we want to show siblings of the current position, even at the top level. we can have a special "dot" location for when you aren't on a binding.

@xzxzlala
Copy link
Contributor Author

@xzxzlala I think we actually want to include let bindings of regular values, not just functions, in the list + we want to show siblings of the current position, even at the top level. we can have a special "dot" location for when you aren't on a binding.

Sure, I will add the "dot" for cursor not in bindings.
I'm a little bit confused about using let binding of regular values. Won't that lead to lots of levels (fill all the room for top bar)?

@cyrus-
Copy link
Member

cyrus- commented Dec 11, 2023

@xzxzlala I think we actually want to include let bindings of regular values, not just functions, in the list + we want to show siblings of the current position, even at the top level. we can have a special "dot" location for when you aren't on a binding.

Sure, I will add the "dot" for cursor not in bindings. I'm a little bit confused about using let binding of regular values. Won't that lead to lots of levels (fill all the room for top bar)?

It will add more items to the dropdown but it shouldn't increase the horizontal width much since that is based on depth -- it isn't common to nest let bindings very deeply.

@xzxzlala
Copy link
Contributor Author

@xzxzlala I think we actually want to include let bindings of regular values, not just functions, in the list + we want to show siblings of the current position, even at the top level. we can have a special "dot" location for when you aren't on a binding.

Sure, I will add the "dot" for cursor not in bindings. I'm a little bit confused about using let binding of regular values. Won't that lead to lots of levels (fill all the room for top bar)?

It will add more items to the dropdown but it shouldn't increase the horizontal width much since that is based on depth -- it isn't common to nest let bindings very deeply.

I see, I misunderstand that. We want all other regular values to be siblings in same level and when in the body of new functions/modules we add another level.

@cyrus-
Copy link
Member

cyrus- commented Dec 11, 2023

There would be a new level whenever one binding is nested in another, so also in

let x = 
  let y = 2| in 
  y + 1
in 
x

@disconcision
Copy link
Member

k i'm good to restyle if you want. when this is current with dev i'll branch off and do the restyling, then PR against this

@cyrus-
Copy link
Member

cyrus- commented Feb 27, 2024

Seems to be quite buggy right now -- try moving around the following program:

let x = 2 * 3 in 
let y = 3 * 4 in 
let z = 2 * 3 in 
x

It should indicate x only when in the expression 2 * 3 but it indicates z there. Similar issues elsewhere.

@cyrus- cyrus- marked this pull request as draft February 29, 2024 05:21
@xzxzlala xzxzlala marked this pull request as ready for review March 13, 2024 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-merge for PRs that need a merge from dev needs-polish for PRs that are substantially complete but need final polish
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants