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

Strange lines source code of conduit #7

Open
qrilka opened this issue Oct 10, 2018 · 2 comments
Open

Strange lines source code of conduit #7

qrilka opened this issue Oct 10, 2018 · 2 comments
Assignees

Comments

@qrilka
Copy link

qrilka commented Oct 10, 2018

Namely https://haskell-code-explorer.mfix.io/package/conduit-1.3.0.2/show/src/Data/Conduit/Combinators.hs seems to contain some output from CPP preprocessor or some other tool

@alexwl
Copy link
Owner

alexwl commented Oct 10, 2018

That's true, these lines were added by the C preprocessor (CPP). It's the correct behavior of Haskell code explorer at the moment.

When CPP is only used for conditional compilation, then it is OK to show the source code before CPP pass: https://haskell-code-explorer.mfix.io/package/attoparsec-0.13.2.2/show/tests/QC/Combinator.hs#L5 (everything is readable and locations of Haskell identifiers are correct).

However, CPP may also be used to add new lines of code (e.g., with #include pragma). In that case, the source code before CPP pass may be unreadable. For example, it is impossible to see the source code of System.FilePath.Posix module on Hackage (Haddock shows the source code before CPP pass): https://hackage.haskell.org/package/filepath-1.4.2.1/docs/src/System.FilePath.Posix.html.

Haskell code explorer attempts to choose the most 'readable' form of the source code (before CPP pass vs after CPP pass). The logic is the following (https://haskell-code-explorer.mfix.io/package/haskell-code-explorer-0.1.0.0/show/src/HaskellCodeExplorer/Preprocessor.hs#L65): if there is an #include pragma in a file, then Haskell code explorer shows the source code after CPP pass, otherwise, it shows the source code before CPP pass. This logic allows showing the source code of System.FilePath.Posix module correctly: https://haskell-code-explorer.mfix.io/package/filepath-1.4.2/show/System/FilePath/Posix.hs#L268.

The source code of src/Data/Conduit/Combinators.hs contains an #include pragma (https://github.com/snoyberg/conduit/blob/87e4c64300054014f1d3db1cbae4d67d5ca35292/conduit/src/Data/Conduit/Combinators.hs#L264), therefore Haskell code explorer shows the source code after CPP pass.

I'm open to ideas on how to improve the "before CPP pass vs after CPP pass" logic.

@alexwl alexwl self-assigned this Oct 10, 2018
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

2 participants