Problem with hierarchical libraries in Hugs compared to ghc/nhc98
Ross Paterson
ross@soi.city.ac.uk
Fri, 7 Mar 2003 15:09:30 +0000
On Fri, Mar 07, 2003 at 02:35:47PM +0000, Olaf Chitil wrote:
> When trying to make our Haskell tracer Hat work with Hugs (November
> 2002) I noticed that
>
> * Hugs' implementation of hierarchical libraries differs from those
> of ghc and nhc98, and
> * Hugs' implementation choice makes it more restrictive than ghc/nhc98
>
> A simple example:
> There is module B in file B.hs
> There is module Test.B in file Test/B.hs
> There is module Test.A in file Test/A.hs
> Module Test.A contains "import B".
>
> When compiling module Test.A both nhc98 and ghc imports module B from
> file B.hs. In contrast, Hugs imports module Test.B from file Test/B.hs
> and then stops with an error, because the module name is wrong.
>
> The simple reason why Hugs behaves so is that when searching a module it
> *always* searches the current directory (* where the import was demanded
> *) first. Only afterwards the paths set with the -P option are searched.
>
> [noble attempt at rationalizing Hugs's behaviour omitted]
This is a clear flaw in Hugs (long known, but hard to fix). A workaround
is to add the -X option to stop it adding the extra directory.