This one is my fault.
I was trying to reduce the number of module dependencies that are
recorded in a .hi file. There isn't much point in recording which
version of which functions from the prelude you are using. So I needed
to distinguish a "library" module from a "user" module. I did this
by a hack: modules imported from a directory with an absolute pathname
are considered "library" modules.
But the dependency information also records which imported modules
have "orphan" instance declarations; that is, instance decls for
a class and type declared elsewhere. I really need to keep this info
even for library modules, and I have fixed this bug.
So it was very confusing (sorry), and remains a bit of a hack.
I'd better document the hack, else the recompilation checker (that says
when something doesn't need to be recompiled) will go wrong.
Simon
> -----Original Message-----
> From: George Russell
> Sent: Monday, August 02, 1999 2:37 PM
> To: [EMAIL PROTECTED]
> Subject: Instance declarations get lost from modules imported from
> absolute paths
>
>
> The attached tgz archive contains 4 files:
> A.hs defines a type X and a type class Y
> B.hs imports A and makes X an instance of Y
> C.hs imports B and just exports everything again
> D.hs imports C and tries to use the fact that X is an instance of Y.
>
> If you compile this using
> ghc -c [A/B/C/D].hs
> then it should all go swimmingly (by the way, we are on
> Sparc-Solaris and using a version
> downloaded at the end of last week).
>
> If however you compile it using
> ghc -c [A/B/C/D].hs -i$PWD
> (replace $PWD by the absolute path of directory containing
> A,B,C,D, if your shell doesn't)
> then it doesn't work. The reason is that C.hi now only
> contains the following:
>
> __interface C 1 404 where
> __export A X{FOO BAR} Y{p};
>
> where it previously contained
>
> __interface C 1 404 where
> __export A X{FOO BAR} Y{p};
> import A 1 ::;
> import B 1 ! ::;
>
> In other words it looks as if, because A and B were obtained
> from an absolute path,
> ghc has decided to forget to add them to C's import list, so
> that the instance declaration
> in B gets lost.
>
> This is really exceptionally confusing. I am not sure if it
> is intended or not, but I
> certainly don't like it, and it doesn't seem to be
> documented. If the use of
> absolute path names for interface files is deprecated then ITWSBT!
>
RE: Instance declarations get lost from modules imported from abs olute paths
Simon Peyton-Jones Tue, 24 Aug 1999 11:27:54 +0200 (MET DST)
