Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,931
    • Issues 4,931
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 464
    • Merge requests 464
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #16358
Closed
Open
Created Feb 23, 2019 by Levent Erkök@LeventErkokReporter

Confusing ghci error message

$ ghci
GHCi, version 8.6.3: http://www.haskell.org/ghc/  :? for help
Prelude> import qualified Data.Set as S
Prelude S> S.foo

<interactive>:2:1: error:
    Not in scope: ‘S.foo’
    No module named ‘S’ is imported.

I'm curious why ghci says No module named 'S' is imported. I found it very confusing.

I'd have expected it to say one of three things:

  1. Module Data.Set referenced via S does not export foo
  2. Constructor S not in scope
  3. Variable foo not in scope

The first one would be the most informative, but I can see that the second and the third messages might be quite reasonable as well due to the interpretation of dot as composition. But the message No module S is imported is quite confusing given I just issued import qualified Data.Set as S.

Indeed, if I put this in a file, the error message is crystal clear:

$ cat a.hs
import qualified Data.Set as S

bar = S.foo

$ ghci a.hs
GHCi, version 8.6.3: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( a.hs, interpreted )

a.hs:3:7: error:
    Not in scope: ‘S.foo’
    Module ‘Data.Set’ does not export ‘foo’.
  |
3 | bar = S.foo
  |       ^^^^^
Failed, no modules loaded.

I'm curious why there's a difference between these two scenarios.

Edited Mar 10, 2019 by Levent Erkök
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking