Simon Marlow
Mon, 9 Sep 2002 14:01:59 +0100

> I have two questions, related to packages.
> 1) What is the relationship between the new and cool
> hierarchical module structure and packages? Packages used to
> be a way of avoiding name clashes on module level, but that
> role has been taken over by the new module system.

There are still two reasons for packages to exist:

  - they are a useful unit of distribution

  - they reduce link times and GHCi startup time compared
    to having all your libraries always linked in

A separate question is whether you should have to say explicitly
'-package foo' on the command line in order to get access to package
foo.  Simon & I have discussed this and come up with the following

  - package which contain hierarchical modules should be marked
    'auto' in the package config.

  - any package marked 'auto' is always available when using
    ghc --make and GHCi.  The compiler can infer which packages
    are actually used and link them in as required (I believe
    the machinery for this is in place as part of Simon's Template
    Haskell work).

  - packages not marked 'auto' have to be specified on the command

  - for "one-shot" compilation, i.e. without --make, we can either
    require you to specify the 'auto' packages, or just link them all
    in.  I'm not sure which I prefer.

> Several sub-questions:
>   - I can add my own packages, can I add my own modules to
>     the hierarchy?

Yes, a package can contain hierarchical modules.

>   - Can the package system be complete taken over by the
>     module system? I.e. relating certain .a, .so, .dll files
>     and compiler flags with certain parts of the module
>     hierarchy?

That's essentially what the package system does.  Every interface file
currently contains the name of the package to which it belongs.  We
*also* separate packages in the file system, but that isn't necessary.

> 2) I am trying to install my own package. I do not have
> write access to GHC's package.conf. So, I make my own. But:
> >>>
> [cth/Yahu] -: more yahu.conf
> [Package
>     {name =3D "yahu",
>      import_dirs =3D ["/users/cs/koen/Code/Ghc/Yahu"],
>      source_dirs =3D [],
>      library_dirs =3D ["/users/cs/koen/Code/Ghc/Yahu"],
>      hs_libraries =3D [],
>      extra_libraries =3D [],
>      include_dirs =3D [],
>      c_includes =3D [],
>      package_deps =3D [],
>      extra_ghc_opts =3D [],
>      extra_cc_opts =3D [],
>      extra_ld_opts =3D ["-lyahu"],
>      framework_dirs =3D [],
>      extra_frameworks =3D []}]
> [cth/Yahu] -: ghc --package-conf yahu.conf -package yahu --make Test
> ghc-5.04: unknown package name: yahu
> <<<

The -package-conf option only has one dash.  Due to the way GHC parses
options, the missing package is reported before the unrecognised flag.
It's regrettably confusing, I know.