Problem with hierarchical libraries in Hugs compared to ghc/nhc98
Wed, 12 Mar 2003 10:16:29 +0000
On Mon, Mar 10, 2003 at 07:53:57PM +0000, Olaf Chitil wrote:
> Ross Paterson wrote:
> > In my opinion the correct fix is to add the directory only if the parent
> > module was specified with a path, or was itself found relative to that
> > added directory.
> I agree. So a search directory is only passed on recursively, if the
> imported module is actually found in that directory.
I've had a look, and it's not so hard to do what I suggested, but the
changes would be cleaner if the search strategy for module names, currently
[ d++f++e | f <- files, d <- dirs, e <- hugsSuffixes ]
dirs = addAlong ("" : hugsPath)
files = [mod2dir nm, nm]
| wantImplicitRoot = (along:)
| otherwise = id
mod2dir s = map (\c -> if c=='.' then slash else c) s
were also changed to
[ d++f++e | d <- dirs, f <- files, e <- hugsSuffixes ]
i.e. swap the first two generators. I think that having the generator
order match the concatenation order is more comprehensible; it's also
closer to what GHC does (except GHC has files = [nm, mod2dir nm]).
It does sometimes mean checking a few more files before finding a match,
but not always adding the extra directory will also save some checks.