haskell / haskell/cabal

mixins prevent use of -XPackageImports

Open
#7,201 3 comments 1 reaction 0 assignees View on GitHub
blocked: ghc cabal-install: Backpack
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

Description
=========
Adding a mixin for a package prevents me from using `-XPackageImports` with that package.

Reproduction
==========
I provide a simple `foo.cabal` package:
```
❯ cat foo.cabal
cabal-version: 2.2
name: foo
version: 0.1

library
exposed-modules: Foo
build-depends:
, base
, microlens
mixins:
, base hiding (Prelude)
```
And `Foo.hs`:
```
❯ cat Foo.hs
{-# language PackageImports, NoImplicitPrelude #-}

module Foo where

import "base" Data.Maybe
import "microlens" Lens.Micro
```
An attempt to build:
```
❯ cabal v2-build
Build profile: -w ghc-8.10.2 -O1
In order, the following will be built (use -v for more details):
- foo-0.1 (lib) (file Foo.hs changed)
Preprocessing library for foo-0.1..
Building library for foo-0.1..
[1 of 1] Compiling Foo ( Foo.hs, /home/chessai/haskell/repros/package-imports-mixins/dist-newstyle/build/x86_64-linux/ghc-8.10.2/foo-0.1/build/Foo.o, /home/chessai/haskell/repros/package-imports-mixins/dist-newstyle/build/x86_64-linux/ghc-8.10.2/foo-0.1/build/Foo.dyn_o )

Foo.hs:5:1: error:
Could not load module ‘Data.Maybe’
It is a member of the hidden package ‘base-4.14.1.0’.
Perhaps you need to add ‘base’ to the build-depends in your .cabal file.
|
5 | import "base" Data.Maybe
| ^^^^^^^^^^^^^^^^^^^^^^^^
```

Now, `Foo.hs` _after_ removing `-XPackageImport` on the import from `base`:
```
❯ cat Foo.hs
{-# language PackageImports, NoImplicitPrelude #-}

module Foo where

import Data.Maybe
import "microlens" Lens.Micro
```
Which builds just fine:
```
haskell/repros/package-imports-mixins via ❄️ impure (shell)
❯ cabal v2-build
Build profile: -w ghc-8.10.2 -O1
In order, the following will be built (use -v for more details):
- foo-0.1 (lib) (file Foo.hs changed)
Preprocessing library for foo-0.1..
Building library for foo-0.1..
[1 of 1] Compiling Foo ( Foo.hs, /home/chessai/haskell/repros/package-imports-mixins/dist-newstyle/build/x86_64-linux/ghc-8.10.2/foo-0.1/build/Foo.o, /home/chessai/haskell/repros/package-imports-mixins/dist-newstyle/build/x86_64-linux/ghc-8.10.2/foo-0.1/build/Foo.dyn_o )
```

Expected behavior
===============
Mixins should not preclude a package from the use of `-XPackageImports`. I expect that both versions of `Foo.hs` would build.

System Information
===============
OS: NixOS
Cabal version:
```
❯ cabal --version
cabal-install version 3.2.0.0
compiled using version 3.2.0.0 of the Cabal library
```
GHC version:
```
❯ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.2
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.