
Fergus Henderson
(>>) = 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