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

[pysa][MLH] Add a show to Registry #869

Open
arthaud opened this issue May 31, 2024 · 0 comments
Open

[pysa][MLH] Add a show to Registry #869

arthaud opened this issue May 31, 2024 · 0 comments

Comments

@arthaud
Copy link
Contributor

arthaud commented May 31, 2024

When debugging, it can be useful to print the content of a Registry:
https://github.com/facebook/pyre-check/blob/main/source/interprocedural/fixpointAnalysis.ml#L143

Unfortunately, it does not currently implement pp or show. Let's add those.

Note that we can use something like this to pretty print a map-like structure:

let pp_map pp_value formatter map =
    let pp_pairs pp_value formatter pairs =
      let pp_pair formatter key value =
        Format.fprintf formatter "@,%s -> [%a]" key pp_value value
      in
      iter (pp_pair formatter) pairs
    in
    Format.fprintf formatter "{@[<v 2>%a@]@,}" (pp_pairs pp_value) map

let show ~pp_value map = Format.asprintf "%a" (pp_map pp_value) map

This is tracked internally by T123569270.

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

No branches or pull requests

1 participant