Bug in file-name imports?

Johan Nordlander nordland@cse.ogi.edu
Sun, 16 Dec 2001 14:40:09 -0800


On Sunday, December 16, 2001, at 03:14  AM, John Hughes wrote:

> The way a filename is interpreted in an import, such as
> =A0
> =A0=A0=A0 import "src/M"
> =A0
> has changed under the December 2001 version of hugs.=20
> Previously, the filename was interpreted relative to the=20
> location of the importing module. That seems no longer to be=20
> the case (although I'm not sure where hugs does look nowadays).
> =A0
> As a result, it's now impossible to load Fran, which places a=20
> few "public" modules in the directory you add to your path, and=20
> then loads many more from the src subdirectory. The idea is to=20
> avoid cluttering the module name space with all the internal=20
> modules.
> =A0
> Is this a deliberate change? I didn't find any information on=20
> it in the notes on the new release, so I assume it's a bug.
>

Hugs now support the hierarchical module namespace extension,=20
pretty much as it is described in Malcolm Wallace's proposal=20
(http://www.cs.york.ac.uk/fp/libraries/).  Hugs also allows file=20
names in import clauses as another extension, but to in order to=20
simplify the already complex mapping of import declarations to=20
files, Hugs no longer performs any advanced searching in the=20
latter case.

The hope is of course that programmers will start using the new=20
feature.  In the case of Fran that would mean renaming the src=20
directory Src, changing "src/M" in an import list to Src.M, and=20
finally change the name for every module M in Src to Src.M.

The current file mapping algorithm can be described by the=20
following Haskell program, where the result represents the order=20
in which files are examined, and where "along" stands for the=20
location of the importing module.

   find along nm hugspath
     | isModuleId nm =3D [ d++f++e | f <- files, d <- dirs, e <- exts ]
     | otherwise     =3D [ nm ++ e | e <- "" : exts ]
     where
       dirs          =3D along : "" : hugspath
       files         =3D [mod2dir nm, nm]
       exts          =3D [".hs",".lhs"]

       isModuleId s  =3D all isConid (splitAt '.' s)
       mod2dir s     =3D map (\c -> if c=3D=3D'.' then slash else c) s

All the best,
Johan