[Hat] Hat bug report: Ambiguous occurrence `List'

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Wed Jun 30 10:48:48 EDT 2004


Fergus Henderson <fjh007 at galois.com> writes:

> > > 	(>>) = 42
> 
> The name ">>" is defined in the Prelude, but this occurrence of ">>"
> in Foo.hs is a definition, so it unambiguously refers to Main.>>,
> not Prelude.>>.

Yes, OK, accepted.

The problem here is that the Hat transformation introduces three
replacement definitions for the original function: a worker, a
wrapper, and an atom.  The worker is used on the RHS of the wrapper
definition, and the atom is used on the RHS of the worker definition.
These RHS usages should be qualified for disambiguation.  Thus,
hat-trans ought to check whether a top-level variable is already
in scope at its point of definition, and if so, qualify those newly
introduced uses.

Unfortunately, it looks like a considerable amount of internal plumbing
will need to be added to hat-trans to enable this check.

In the meantime, a plausible workaround would be:

  import Prelude hiding ((>>))
  import qualified Prelude
  (>>) = 42

but at the moment, this does not work either, because the transformed
version only hides the imported wrapper function (!>>) but not the
worker (|>>) or atom (+>>).  I have attached a possible fix, but
with it, the Hat prelude can no longer be transformed correctly,
so you should not try to rebuild that.  Olaf might like to comment
on or refine the patch.

Regards,
    Malcolm

-------------- next part --------------
Index: src/hattrans/TraceTrans.hs
===================================================================
RCS file: /home/cvs/root/hat/src/hattrans/TraceTrans.hs,v
retrieving revision 1.65
diff -u -r1.65 TraceTrans.hs
--- src/hattrans/TraceTrans.hs	29 Jun 2004 12:52:06 -0000	1.65
+++ src/hattrans/TraceTrans.hs	30 Jun 2004 14:47:04 -0000
@@ -207,6 +207,8 @@
   : case arity id of
       Just a | a > 0 -> [EntityVar pos (nameTraceInfoGlobalVar id)
                         ,EntityVar pos (nameWorker id)]
+      Just (-1)      -> [EntityVar pos (nameTraceInfoGlobalVar id)
+                        ,EntityVar pos (nameShare id)]
       _              -> []
 tEntity traced (EntityConClsAll pos id) | hasValueInfo id = []
 tEntity traced (EntityConClsAll pos id) =


More information about the Hat mailing list