haskell-code-explorer
haskell-code-explorer copied to clipboard
Strange lines source code of conduit
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
http://hackage.haskell.org/package/conduit-1.3.0.2/docs/src/Data-Conduit-Combinators.html and https://github.com/snoyberg/conduit/blob/87e4c64300054014f1d3db1cbae4d67d5ca35292/conduit/src/Data/Conduit/Combinators.hs don't show lines from 1 to 251 shown by code explorer
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.