Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import Prelude hiding ... isn't working in a cabal repl shell #10786

Open
yaxu opened this issue Feb 9, 2025 · 0 comments
Open

import Prelude hiding ... isn't working in a cabal repl shell #10786

yaxu opened this issue Feb 9, 2025 · 0 comments

Comments

@yaxu
Copy link

yaxu commented Feb 9, 2025

Describe the bug

Hiding functions from Prelude with import Prelude hiding ... doesn't work in cabal repl. It works fine in ghci.

To Reproduce
Steps to reproduce the behavior:

  • make a dummy library package with cabal init
  • add containers to build-depends
  • run cabal repl

Try hiding something from prelude:

ghci> import Prelude hiding (map)
ghci> import Data.Map
ghci> :t map
<interactive>:1:1: error: [GHC-87543]
    Ambiguous occurrence ‘map’.
    It could refer to
       either ‘Prelude.map’,
              imported from ‘Prelude’ at src/MyLib.hs:1:8-12
              (and originally defined in ‘ghc-internal-9.1201.0:GHC.Internal.Base’),
           or ‘Data.Map.map’,
              imported from ‘Data.Map’
              (and originally defined in ‘Data.Map.Internal’).

A more minimal test:

ghci> import Prelude hiding (map)
ghci> :t map
map :: (a -> b) -> [a] -> [b]

It seems hiding is ignored.

Expected behavior

function from Prelude gets hidden to avoid error when overloading it from another package.

It works in a plain ghci shell:

ghci> import Prelude hiding (map)
ghci> import Data.Map
ghci> :t map
map :: (a -> b) -> Map k a -> Map k b

System information

  • linux
  • cabal-3.14.1.1, ghc-9.12.1 (latest), and cabal-3.12.1.0.0 / ghc-9.4.8 (recommended)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant