GHC refuses to export qualified modules

前端 未结 2 478
情书的邮戳
情书的邮戳 2021-02-12 17:52

I want to write a module which re-exports some module it had imported qualified. Something like this:

module Foo.A
  ( module Foo.B
  , module Foo.C
  ) where
im         


        
2条回答
  •  感情败类
    2021-02-12 18:18

    No, that isn't just a limitation of GHC, it's the way import and export is designed to work in Haskell.

    A module only has control of its own namespace - it can't affect what people can see from other namespaces. A module "re-export" is just a shorthand to say "export all of the symbols in my own namespace that happen to have been imported here from that other module". But symbols that you imported qualified aren't really in your own namespace.

    If you want to export two different symbols that have the same name, you won't be able to do it from one module. Split the module into two, and export each version from a different module.

提交回复
热议问题