What if two modules have the same name?

I have two packages that provide modules with the same name. When I try to load a module, I get an error

An ambiguous interface for ....: It has been found in several packages.

What to do to resolve this?

To be specific, package cryptoniteand crypto-apiprovide modules named Crypto.Random. How can I indicate which package I want to load from a module?

+6
source share
2 answers

You can use the language pragma PackageImportsand explicitly select the package that you mean in your import statement, for example:

import "cryptonite" Crypto.Random

, , , , cabal, cabal.

+7

ghc >= 8.2 cabal-install >= 2.0, - mixins cabal:

  build-depends:       base >=4.10 && <4.11,
                       cryptonite >= 0.24,
                       crypto-api >= 0.13.2
  mixins:
                       cryptonite (Crypto.Random as CryptoniteCrypto.Random),
                       crypto-api (Crypto.Random as CryptoAPICrypto.Random)

:

module Main where

import CryptoniteCrypto.Random
import CryptoAPICrypto.Random

, , , , , .

, , GHC 7.10, - . ( ), mixins ( ).

+8

All Articles