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

WIP: Derive Inspect #5775

Merged
merged 40 commits into from
Nov 29, 2023
Merged

WIP: Derive Inspect #5775

merged 40 commits into from
Nov 29, 2023

Conversation

rtfeldman
Copy link
Contributor

No description provided.

@github-actions
Copy link

Thank you for your contribution! Sometimes PRs end up staying open for a long time without activity, which can make the list of open PRs get long and time-consuming to review. To keep things manageable for reviewers, this bot automatically closes PRs that haven’t had activity in 60 days. This PR hasn’t had activity in 30 days, so it will be automatically closed if there is no more activity in the next 30 days. Keep in mind that PRs marked Closed are not deleted, so no matter what, the PR will still be right here in the repo. You can always access it and reopen it anytime you like!

ayazhafiz
ayazhafiz previously approved these changes Nov 28, 2023
@@ -126,6 +130,11 @@ isEq = \xs, ys ->
hashDict : hasher, Dict k v -> hasher where k implements Hash & Eq, v implements Hash, hasher implements Hasher
hashDict = \hasher, dict -> Hash.hashUnordered hasher (toList dict) List.walk

toInspectorDict : Dict k v -> Inspector f where k implements Inspect & Hash & Eq, v implements Inspect, f implements InspectFormatter
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
toInspectorDict : Dict k v -> Inspector f where k implements Inspect & Hash & Eq, v implements Inspect, f implements InspectFormatter
toInspectorDict : Dict k v -> Inspector f where k implements Inspect, v implements Inspect, f implements InspectFormatter

Those are redundant, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is required for some reason:

This expression is used in an unexpected way:

  133│  toInspectorDict : Dict k v -> Inspector f where k implements Inspect, v implements Inspect, f implements InspectFormatter
                               ^

  This argument to an opaque type has type:

      k where k implements Inspect

  But you are trying to use it as:

      #a where #a implements Hash & Eq

  Note: The type variable k says it can take on any value that
  implements only the ability Inspect.

  But, I see that it's also used as if it implements the abilities Hash
  and Eq. Can you use k without those abilities? If not, consider adding
  them to the implements clause of k.

Comment on lines +102 to +105
# The current default formatter for inspect.
# This just returns a simple string for debugging.
# More powerful formatters will likely be wanted in the future.
DbgFormatter := { data : Str }
Copy link
Member

Choose a reason for hiding this comment

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

Not important right now, but I wonder if we should split this out into a separate module.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I debated the same, but ultimately thought it would be nicer to just have Inspect.toDbgStr. I am open to either, but that can be dealt with in follow up.

crates/compiler/can/src/derive.rs Show resolved Hide resolved
crates/compiler/derive/src/inspect.rs Outdated Show resolved Hide resolved
crates/compiler/derive/src/inspect.rs Outdated Show resolved Hide resolved
crates/compiler/solve/src/specialize.rs Outdated Show resolved Hide resolved
@@ -3289,3 +3289,150 @@ fn non_nullable_unwrapped_instead_of_nullable_wrapped() {
"#
)
}

#[mono_test]
#[ignore = "Hits an unimplemented for abilities, not sure why..."]
Copy link
Member

Choose a reason for hiding this comment

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

Is this still the case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, still fails, also fails in a similar test for encode. Haven't dug into it much:

thread 'inspect_custom_type' panicked at '[Abilities] not yet implemented. Tracking issue: https://github.com/roc-lang/roc/issues/2463.
Additional information: Not reachable yet', crates/compiler/mono/src/layout.rs:511:55

@@ -1754,6 +1756,7 @@ impl Subs {
symbol_names.push(Symbol::HASH_HASHER);
symbol_names.push(Symbol::HASH_HASH_ABILITY);
symbol_names.push(Symbol::BOOL_EQ);
symbol_names.push(Symbol::INSPECT_INSPECT_ABILITY);
// END INIT-SymbolNames
Copy link
Member

Choose a reason for hiding this comment

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

Curse of IFTTT... we should rename to "INIT-SymbolSubsSlice" ( sorry, I know it's not due to this PR)

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't truly follow, but renamed.

@ayazhafiz
Copy link
Member

I approved, but if possible, we should address the comments related to things introduced in this PR (the other stuff, which was introduced previously, I can fixup)

@bhansconnect
Copy link
Contributor

@rtfeldman, can we force merge this. Seems that the CI runner is just broken currently. This PR and a few other are just waiting in queue. I have run all the tests locally which is a nix macos apple silicon machine. Also, nothing was changed for any dev tools.

@bhansconnect bhansconnect merged commit ead9031 into main Nov 29, 2023
16 checks passed
@bhansconnect bhansconnect deleted the inspect-derive branch November 29, 2023 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants