
#10871: Implement "fat" interface files which can be directly compiled without source -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: backpack Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by ezyang): Posting a little update about the tiresome root main function: the root main function is a special implicit binding that is added to Haskell programs during type checking and serves as the "well known" entry point to enter a Haskell program. Currently, it is named `:Main.main` (i.e. `ZCMain_main`): unusually, it is a binding in a Haskell program that can have a different `Module` than the module actually being compiled. Because of this, it has to be treated specially when we serialize it out to an interface file: namely, we have to know /which/ binding is the root main binding (so it doesn't clobber the user-written main binding), as interface file serialization doesn't record `Module`, only the `OccName`. In our last phone call, we proposed two fixes, but I don't think either of them will work: 1. Move the binding to be injected during tidying, rather than typechecking. This is tiresome because `main` is to have type `IO a`, where `a` is anything we want. We'd have to extract out this type to make a well-formed core binding (this is marginally easier in the typechecker, where the current code does unification to pull it out.) We are also only given the `RdrName` of the function which is supposed to be main; we have to consult the `GlobalRdrEnv` to turn this into an actual `Name`. So we also have to make sure to preserve this information until the final tidying so that we can point to the correct main function, which means yet another thing to record in `ModGuts`. Finally, we can't really eliminate `checkMain`, since we need to give errors when appropriate. So this is a large amount of work for a questionable amount of benefit. 2. Rename the main `OccName` to something special, e.g. `$main`, so we can identify it in the interface file. If we do this, it means the name that you must refer to for a Haskell program for main, `ZCMain_main_closure`, has to be renamed to `ZCMain_zdmain_closure`. This is pretty gratuitous and will break any C-Haskell bridges for no good reason. So I'd like not to do that. I think my current plan is to just have a flag in `IfaceBinding` which says if this is "main" or not, and then we just typecheck it accordingly one way or another. A small amount of code, no penalty for normal interface files, and very simple. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10871#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler