PackageImports chooses an arbitrary component when there are multiple libraries in a package
I have a cabal file which declares a few sublibraries.
cabal-version: 3.0
name: rexp-demo
version: 0.1.0.0
license: NONE
author: matthewtpickering@gmail.com
maintainer: Matthew Pickering
build-type: Simple
extra-doc-files: CHANGELOG.md
common warnings
ghc-options: -Wall
executable rexp-demo
build-depends: rexp-demo, base
main-is: Main.hs
library
import: warnings
exposed-modules: MyLib
build-depends: base ^>=4.18.0.0, a, b
hs-source-dirs: src
default-language: Haskell2010
library a
exposed-modules: A
hs-source-dirs: src-a
build-depends: base ^>=4.18.0.0
library b
exposed-modules: A
hs-source-dirs: src-b
build-depends: base ^>=4.18.0.0
When I use package imports to "disambiguate" then this program compiles and chooses (arbitrarily library a to provide the A
module).
{-# LANGUAGE PackageImports #-}
module MyLib (f) where
import "rexp-demo" A
f = a
If I remove the package import then it complains about an ambiguous module.
src/MyLib.hs:6:1: error:
Ambiguous module name ‘A’:
it was found in multiple packages:
rexp-demo-0.1.0.0:a rexp-demo-0.1.0.0:b
|
6 | import A
| ^^^^^^^^
The program shouldn't choose arbitrarily (or via some rule) to prefer a
over b
.
Ideally the PackageImports
extension should have a syntax to allow me to precisely state that I want library a
or library b
.