The issue in Haskell:
module Foo.A where foo = 42
and
module Foo.B where foo = 12
and you want to write a super module
module Foo ( module Foo.A , module Foo.B ) where import Foo.A import Foo.B
which re-exports those modules, you would get a name clash.
Note, there can be plenty of the functions like foo
in each module (foo1, foo2, etc) and I want to use them from both modules. There can also be data
s with the same member names in each module, after all. So hiding isn't a solution. I do not consider Lens for resolving it.
Now, does Frege solve the problem of "re-export qualified" of Haskell? It seems it does if I remember correctly, but I can't find the evidence now, can anyone elaborate on that?
I guess it doesn't. In Frege, a module can re-export items only (ie functions, types, type classes), but not modules.
This means that, if you have some foo
s down in the module hierarchy you are importing, you still need to hide all but at most one.
What you can do in Frege is:
import mod.A(foo fooA)
import mod.B(foo fooB)
which effectively renames A.foo
to fooA
and B.foo
to fooB
in the importing module. This works also on re-exports. For example, in frege.Prelude
we have
import Prelude.PreludeBase public(!= /=)
This will cause anyone who imports frege.Prelude
to have the operator /=
available. But this is only an alias for the !=
operator of Ord
As one can imagine, we need to have both !=
and /=
in order to avoid complaints form the Java or Haskell camps, respectively.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.