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

Detecting whether a file contains module Main #14

Open
nh2 opened this issue Sep 12, 2013 · 2 comments
Open

Detecting whether a file contains module Main #14

nh2 opened this issue Sep 12, 2013 · 2 comments

Comments

@nh2
Copy link
Contributor

nh2 commented Sep 12, 2013

As noted in the code already:

TODO: To fully emulate GHC's behaviour, we must know whether the input module
set contains a module Main.

Consider these two invocations:

$ ghc --make Module.hs Module0.hs
[1 of 2] Compiling Module           ( Module.hs, t/Module.o )
[2 of 2] Compiling Module0          ( Module0.hs, t/Module0.o )

$ ghc --make Module.hs Main.hs
[1 of 2] Compiling Module           ( Module.hs, t/Module.o )
[2 of 2] Compiling Main             ( Main.hs, t/Main.o )
Linking Main ...

In the first case, the linking step is not performed since there is no module
called 'Main'.

Additionally, the module 'Main' can have an arbitrary source file name, not
necessary 'Main.hs'. This changes the name of the output executable:

$ ghc --make Module.hs MyProg.hs
[1 of 2] Compiling Module           ( Module.hs, t/Module.o )
[2 of 2] Compiling Main             ( MyProg.hs, t/Main.o )
Linking MyProg ...

Let's use this issue for discussion.

@nh2
Copy link
Contributor Author

nh2 commented Sep 12, 2013

As far as I understand, only GHC can detect whether a module ends up as module Main because you can e.g. switch the module name using CPP.

@nh2
Copy link
Contributor Author

nh2 commented Sep 12, 2013

I just realized that this is not a problem any more, since the final ghc pass we do now will detect this correctly.

I addressed it in #15.

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