Correctly import a module with some definitions only visible with qualified names

Suppose that I have a module A

with the names b

, c

.

Now I want to import A somehow and the following names should be available:

  • A.b

  • A.c

  • c

where the unqualified name is hidden b

.

The method I tried is to import A twice in two ways:

import A hiding (b)
import qualified A (b)

      

But it doesn't seem to achieve the effect described above. So what is the correct way to do this?

+3


source to share


1 answer


You should be able to do

import A (c)
import qualified A

      

or



import A hiding (b)
import qualified A

      

which should only provide access to c

and then everything inside A

using qualified syntax. If you are testing this in GHCi, remember that GHCi has some extra special stuff to allow it to get more access in the module that it downloaded from source as its main use is research and debugging.

+3


source







All Articles