
Arun Kumar S Jadhav
Can any one tell me what is the use of .hi (interface) files. I want to know the steps involved in the compilation of a .hs file. I went thru the what nhc98 roughly does and saw that it generates interface file for each module. Please enlighten as to what is the precise function of interface files.
Interface files are a mechanism to permit separate compilation of modules. A module can be compiled by reading just its own source code, plus the interfaces of the modules it imports, rather than needing to read the source code of every module it depends on. The interface file contains (at minimum) the type for each identifier exported from a module M. This is so that, when another module P uses an identifier x from module M, the type inference engine can check the actual type of x against its usage to ensure no type errors have been made. There is often some other essential information held in the .hi files, such as the fixity/associativity/priority of infix identifiers, and declarations of user-defined datatypes. Additionally, some compilers choose to include non-essential but highly useful information in the .hi file, such as strictness, inlining, specialisations, etc. You should note that the Hugs system does not do separate compilation, and so does not use interface files - it does read all the source code for every module of a program. Regards, Malcolm