Proposals for changes to searching behaviour

Simon Marlow
Mon, 9 Dec 2002 12:40:18 -0000

Hi Folks,

Henrik Nillson & I have been discussing the current behaviour of GHC
when searching for modules, particularly in combination with
hierarchical modules, and have identified two ways in which things might
be made more flexible.

The current situation forces you to put sources in a directory hierarchy
which mirrors the module hierarchy.  While simple, this might be
inconvenient, and will certainly be painful when the module hierarchy
gets deeper.  Also, the current situation seems to have caught people
out more than once (perhaps that's a documentation problem, though).  My
own preference is for keeping things as simple as possible, so I'm
generally in favour of the status quo - but we always value feedback
from our users, so please let us know what you think.  Anyway, here's
the two suggestions:

  - The sources for a module A.B.C would be allowed to be placed
    in either A.B.C.hs or A/B/C.hs relative to one of the directories
    in the search path.  Currently only A/B/C.hs is allowed.

    This is an easy change to make, and I believe Hugs already does
    it this way.

  - We could provide the ability to specify a module prefix to associate
    with a directory in the search path.  For example, you could say
    that the directory '.' is associated with the module prefix
    "Graphics.Rendering.OpenGL" and avoid having to place your sources
    in the directory Graphics/Rendering/OpenGL.

    I'm not sure what syntax we'd use for this.  Henrik suggested
    placing the module prefix in square brackets before the directory,
	  ghc -i '-i[Graphics.Rendering.OpenGL].'
    In contrast to the previous suggestion, this would actually save
    some trips to the OS when GHC is looking for files.

Please let us know if either of these would make your life easier, or if
there's anything else you'd like to see.