Sverker Nilsson wrote: >In Ada they have structured a similar kind of code inclusion with >something called "subunits". . . . >body_stub ::= > subprogram_specification IS SEPARATE > | PACKAGE BODY package_simple_name IS SEPARATE; > | TASK BODY task_simple_name IS SEPARATE; > >subunit ::= > SEPARATE (parent_unit_name) proper_body > >[End Quote] > >Also using the package syntax from Ada (to avoid the risk of >overloading the Haskell Module Concept excessively) a direct >translation of the compiler example to use these subunit directives >(without semicolons ;-) would be: > [omitted details of example using proposed Haskell subunits] > >In Ada, they separate specification and implementation of packages. I >think this is partly for information hiding purposes and partly to >help the compiler to separate-compile efficiently. I have only used >the package body part in this example, assuming the specifications be >generated in some magic way. But I actually think that also Haskell >could take advantage of separation of specification and implementation. Body stubs work in Ada because there is always a full specification of the stubbed unit visible at the position of the body stub, so that the compiler has all the information it needs to handle any subsequent references to the stubbed unit. (For packages and tasks, there must be a full specification preceding the body stub, while for subprograms, the specification is part of the body stub.) It is not necessary for the compiler to read the proper body while it is compiling the parent unit, as the proper body provides only implementation details. On the other hand, the parent unit (with its body stubs) must be compiled before the subunit, so that the compiler has access to the declarations in the parent that are to be made visible to the subunit. A corresponding mechanism in Haskell would likewise require separate specification (or interface) and implementation for each subunit. The specification would either need to be part of the body stub, or appear as some kind of prior declaration visible at the position of the body stub. I'm not familiar enough with Haskell modules to say whether they could be readily adapted to this purpose. - Jim Hassett