As you can tell from the title, I'm not sure exactly where the
responsibility for this bug lies.
The symptom: green-card (running under hugs, with runhugs) fails when
running in a project directory built with "ghc -split-objs".
The cause: Green Card does import chasing; that is, when processing a
file containing (say) "import GL_DIS", Green Card will try to find and
process a corresponding Green Card file. It searches first for a
file named "GL_DIS"; if that fails, it will search for "GL_DIS.gc".
If this is in a directory which is being built using ghc with the
"-split-objs" option, then there will be a directory named "GL_DIS".
Consider the following program:
> module Main where
>
> main = catch (do v <- readFile "/etc"; putStrLn ("Success: " ++ v))
> (\_ -> putStrLn "Failed!")
When run under Hugs, this prints "Success: ". When compiled with ghc,
this prints "Failed!".
This difference means that if Green Card is run under Hugs, and it
tries to load the Green Card file corresponding to "import GL_DIS",
and there is a directory named "GL_DIS", green-card will believe that
this is an empty Green Card file, process it (with no effect, because
it's empty; and with no warning or error, because it's present), and
subsequently fail.
So, the question is, "Should readFile on a directory throw an IO
error?" If so, then there is a bug in Hugs; if not, there is a bug
(or at least a severe misfeature) in Green Card (and a bug in the ghc
libraries, which do throw an IO error).
I couldn't find a definitive answer to this question in the Haskell 98
report or library report (although I didn't spend too much time
looking). My personal opinion is that it would be better if an IO
error were thrown, so that Hugs should be changed; but that Green Card
should not depend on this, so that the line:
default_suffixes = ["","gc"]
in GreenCard.lhs should be changed to
default_suffixes = ["gc"]
or
default_suffixes = ["gc",""]
In the meantime, a sufficient workaround is to add "--suffix=gc" to
the green-card command line.
Carl Witty