0

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 datas 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?

Incerteza
  • 32,326
  • 47
  • 154
  • 261

1 Answers1

3

I guess it doesn't. In Frege, a module can re-export items only (i.e. functions, types, type classes), but not modules.

This means that, if you have some foos 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.

Ingo
  • 36,037
  • 5
  • 53
  • 100