Opened 2 years ago

Last modified 2 years ago

#10869 new feature request

Option to dump preprocessed source

Reported by: phischu Owned by:
Priority: low Milestone:
Component: Driver Version: 7.10.2
Keywords: easy Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

It would be awesome if GHC had an option -ddump-preprocessed that dumps the source code for each module after preprocessing. I am not sure what the current definition of "preprocessing" is but I mean the output of at least the following tools: happy, alex, c2hs, hsc2hs and cpp. Additionally even if a module was not subject to any preprocessing it should be dumped anyway.

Use case: I want to parse module files from packages from hackage with haskell-src-exts but find it prohibitively difficult to get the preprocessing right. The idea is that after cabal install with ghc options -ddump-preprocessed -ddump-to-file -dumpdir real_modules you get a complete working set of haskell modules that can be parsed directly without any preprocessing in folder real_modules.

Change History (6)

comment:1 Changed 2 years ago by ezyang

Keywords: easy added

comment:2 Changed 2 years ago by mpickering

I'm fairly sure there is already this option? Maybe it's -E..

comment:3 in reply to:  2 Changed 2 years ago by thomie

Resolution: invalid
Status: newclosed

Replying to mpickering:

I'm fairly sure there is already this option? Maybe it's -E..

Exactly, see: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/modes.html#options-order

The option -E runs just the pre-processing passes of the compiler, dumping the result in a file.

GHC doesn't run happy, alex, c2hs or hsc2hs for you, so I don't think there's anything to do here.

comment:4 Changed 2 years ago by thomie

Or maybe you want --make and -E to work together?

comment:5 Changed 2 years ago by phischu

I am sorry that the request was not clear. -E stops ghc after preprocessing. But I want ghc to work normally but in addition dump the preprocessed source files. So, yes, I kinda want --make and -E to work together.

comment:6 Changed 2 years ago by thomie

Resolution: invalid
Status: closednew
Note: See TracTickets for help on using tickets.