Skip to content

Conversation

@simonmar
Copy link
Collaborator

  1. Ignore Names that come from another source file (TODO)
  2. Ignore Names that come from the current source file but have a
    line number outside the valid range. No idea why this happens, I
    didn't investigate.

Note: stacked on #518

@netlify
Copy link

netlify bot commented May 20, 2025

Deploy Preview for fb-oss-glean canceled.

Name Link
🔨 Latest commit 2c83bdb
🔍 Latest deploy log https://app.netlify.com/projects/fb-oss-glean/deploys/6843e3b8e3080200084b249f

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 20, 2025
@CatherineGasnier
Copy link

Happy to review but not sure I have enough context here. Happy to also test in phabricator and approve if you think that's safe enough.

@simonmar
Copy link
Collaborator Author

@CatherineGasnier let me know if there's anything I can do to help.

@CatherineGasnier
Copy link

Ok some context questions I have:

  • What are #included files in haskell? A quick search didn't yield anything
  • Why do we need them? In what way is the proposed solution a workaround? (I guess I don't quite understand the description because I don't understand #included files)

Not sure it really matters for me to understand the details though. Meanwhile I'll go ahead an "import to fbsource" in the hope that it gets tested in phabricator.

@facebook-github-bot
Copy link
Contributor

@CatherineGasnier has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@simonmar
Copy link
Collaborator Author

@CatherineGasnier

* What are #included files in haskell? A quick search didn't yield anything

In Haskell you can use the C preprocessor by adding {-# LANGUAGE CPP #-}, and then you can use #include to include other files at compile-time, like in C/C++. This causes an issue for the Haskell indexer because the .hie file generated by the compiler only has the original source file name and contents, it doesn't have any #included files.

Fortunately it's rare to use #include in Haskell, but I did come across this in the wild, in GHC itself: https://gitlab.haskell.org/ghc/ghc/-/blob/34e352173dd1fc3cd86c49380fda5a4eb5dd7aef/compiler/GHC/Builtin/PrimOps.hs#L147

* Why do we need them? In what way is the proposed solution a workaround? (I guess I don't quite understand the description because I don't understand #included files)

The solution is a workaround because it's just ignoring any symbols and references that come from a file that is not the primary source file. The right solution would be to track the other source files correctly.

Hope this helps!

@simonmar
Copy link
Collaborator Author

@CatherineGasnier note that this PR is stacked on #518 so you probably want to import the earlier PRs in the stack first.

@simonmar simonmar force-pushed the included-source-files branch from c2e43f9 to 0620fac Compare May 24, 2025 18:42
@simonmar simonmar changed the title [new-hs-indexer] Workarounds to handle #included source files [new-hs-indexer #6] Workarounds to handle #included source files May 24, 2025
@simonmar simonmar force-pushed the included-source-files branch from 0620fac to 2c8b0ae Compare May 30, 2025 16:11
simonmar added 2 commits June 7, 2025 08:44
It's useful to be able to know whether a ref is in an import or export,
e.g. for dead code detection, so let's tag refs with an enum to say what
kind of ref it is.

I changed field names so that the schema change shouldn't trigger a
validation failure (I hope).
1. Ignore Names that come from another source file (TODO)
2. Ignore Names that come from the current source file but have a
   line number outside the valid range. No idea why this happens, I
   didn't investigate.
@simonmar simonmar force-pushed the included-source-files branch from 2c8b0ae to 2c83bdb Compare June 7, 2025 07:01
@facebook-github-bot
Copy link
Contributor

@bochko has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot pushed a commit that referenced this pull request Jun 13, 2025
Summary:
Mostly reconstructing sensible source file paths. See the comments.

With this change I can index all of Hackage (2900+ packages).

Note: stacked on #521

Pull Request resolved: #522

Test Plan:
Imported from GitHub, without a `Test Plan:` line.

Rollback Plan:

Reviewed By: donsbot

Differential Revision: D76544337

Pulled By: bochko

fbshipit-source-id: f526e70745343e233743a069cb62ad8e2f79f9af
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants