[ghc-steering-committee] #216: Qualified Do again, recommendation: accept the alternative

Joachim Breitner mail at joachim-breitner.de
Tue Apr 14 15:27:51 UTC 2020


Hi,

Am Dienstag, den 14.04.2020, 11:36 +0000 schrieb Simon Peyton Jones via
ghc-steering-committee:
> Qualified names like M.foo, which always mean “the foo imported from
> module M – albeit with import-qualified you can change the local
> name”

but it’s not that simple: What if I write

import qualified M1 as M
import qualified M2 as M

and then use M.foo?
Well, it resolves the foo imported from M1, if M1 exports it.
Or from M2, if M2 exports it.
But what if both export it? Then we get an “ambiguity error”…
Unless M1.foo and M2.foo, via re-exports, point to the same original
name.

What is proposed for M.(>>) here is the same logic, with the addition
that it doesn’t matter whether you used “hiding ((>>))” somewhere in
these imports, or imported (), to keep the nice existing rule
      “You only import what you explicitly mention”

In terms of implementation I don’t think the burden is high; GHC
already has that logic for the “M.foo is not in scope, did you want to
add foo to the export list in line x” error message.

Cheers,
Joachim

-- 
Joachim Breitner
  mail at joachim-breitner.de
  http://www.joachim-breitner.de/




More information about the ghc-steering-committee mailing list