[nhc-bugs] hmake builds the wrong thing

Malcolm Wallace Malcolm.Wallace@cs.york.ac.uk
Mon, 17 Dec 2001 11:46:05 +0000


> This one had me puzzled for a few seconds before I spotted what was
> going on!
> 
> $ rm foo*; touch foo.hs foo.lhs; hmake foo.lhs
> nhc98    -c -o foo.o foo.hs

Well, having both foo.hs and foo.lhs in the same directory is
a somewhat dangerous thing.  However, if you are (for instance)
generating the .hs automatically from the .lhs using some kind of
un-literating tool, then it might make some sense.  But in that
case, it would not matter which file was actually compiled...

In any case, you can change hmake to prefer a .lhs over a .hs
with the following patch.

Regards,
    Malcolm

Index: src/hmake/GetDep.hs
===================================================================
RCS file: /usr/src/master/nhc/src/hmake/GetDep.hs,v
retrieving revision 1.6
diff -u -r1.6 GetDep.hs
--- src/hmake/GetDep.hs 2001/03/22 18:45:29     1.6
+++ src/hmake/GetDep.hs 2001/12/17 11:45:17
@@ -134,8 +134,8 @@
                              readFile s >>= \file-> readData p s (f file)
                          else try xs
     in try [ (fixFile opts p ff "gc",  id),
-             (fixFile opts p ff "hs",  id),
-             (fixFile opts p ff "lhs", (unlit name))]
+             (fixFile opts p ff "lhs", (unlit name)),
+             (fixFile opts p ff "hs",  id)]

   rP [] = error ("Can't find module "++name++" in\n\t"++
                  concat (intersperse "\n\t" (".":pathSrc opts))++