Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Re-export qualified - how to solve it nowadays, any solution? [duplicate]

Tags:

module

haskell

I have exactly the same issue as described in this question Re-export qualified?

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.

It was asked 5 years ago, I suppose there might have been some changes since then. Have there been any? If not, there's still no solution for that?

I do not consider Lens for resolving it.

UPDATE:

There can be plenty of the functions 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.

like image 972
Incerteza Avatar asked Oct 31 '22 23:10

Incerteza


1 Answers

There is no new solution, but there is still a solution. First you, as only one foo can be exported you have to decide which one you want to export as the bare foo. Then you just need to hide and alias the other one.

module Foo (
  module Foo.A
, module Foo.B
, bFoo
) where

import Foo.A
import Foo.B hiding (foo)
import qualified B as B

bFoo = B.foo

Ok, it's not really elegant but it's a workaround if you really have to.

like image 100
mb14 Avatar answered Nov 09 '22 15:11

mb14