
I am trying to understand the design of the Haskell interface files. Why are they a separate file rather than having the same data in the object file generated by the compiler? (Naively, it seems to me this would work also. Am I missing something?)
Placing interface information into object files would be a perfectly reasonable design decision for a compiler. The language standard itself does not mandate the use of interface files (although it did once, around Haskell 1.2), nor any particular format, so a compiler is free to use whatever strategy it wishes. Some good reasons for having a separate interface are: they can be human-readable and human-writable (ghc's do not fulfill this criterion); they can be used to bootstrap mutually recursive modules in the absence of any object files (ghc uses .hs-boot files instead); other tools can extract information about modules without having to understand either the full Haskell syntax or the object language. Regards, Malcolm