Opened 6 years ago

Last modified 6 years ago

#2344 new feature request

oddity with package prefixes for data constructors

Reported by: claus Owned by:
Priority: normal Milestone:
Component: GHCi Version: 6.9
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

consider

$ ./ghc-6.9.20080514/bin/ghcii.sh
GHCi, version 6.9.20080514: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Prelude> :browse Data.Time.Clock
getCurrentTime :: IO UTCTime
newtype DiffTime
  = time-1.1.2.0:Data.Time.Clock.Scale.MkDiffTime Data.Fixed.Pico
newtype NominalDiffTime
  = time-1.1.2.0:Data.Time.Clock.UTC.MkNominalDiffTime Data.Fixed.Pico
data UTCTime
  = UTCTime {utctDay :: time-1.1.2.0:Data.Time.Calendar.Days.Day,
             utctDayTime :: DiffTime}
newtype UniversalTime
  = ModJulianDate {getModJulianDate :: Rational}
addUTCTime :: NominalDiffTime -> UTCTime -> UTCTime
diffUTCTime :: UTCTime -> UTCTime -> NominalDiffTime
picosecondsToDiffTime :: Integer -> DiffTime
secondsToDiffTime :: Integer -> DiffTime

there is only one time package installed, so i'm surprised to see any package prefixes at all here

$ ./ghc-6.9.20080514/bin/ghc-pkg.exe find-module Data.Time.\*
c:/fptools/ghc/ghc-6.9.20080514\package.conf:
    time-1.1.2.0

but by what system do some things get prefixes and others don't? are there any invisible modules that need the distinction, or is this an output bug?

Change History (5)

comment:1 Changed 6 years ago by simonmar

  • Difficulty set to Unknown

When you say ':browse M', GHCi pretends you've imported module M for the purposes of determining what's in scope. Everything not exported by M is out of scope, and in order to be completely unambiguous about which names are meant, GHCi gives the fully-qualified name including the package.

The package prefixes are a bit unfortunate because they aren't valid syntax for one thing. OTOH, there might be no way to refer to the identifier in question at all using just a module qualifier.

I don't really know how to improve this easily. Are you worried about consuming the output of :browse by a tool, or just using it interactively?

comment:2 Changed 6 years ago by claus

  • Type changed from bug to feature request

ah, i see. so it is really telling me that the thing is not in scope, while giving me an indication of what it is that is not in scope.

i first noticed the effect via the type tooltips in my haskellmode plugins for vim, which are derived from interpreting the output of :browse! *Main. now i see that the difference is between

import Prelude()
import Data.Time.Clock(getCurrentTime,UTCTime)

which gives the type of getCurrentTime as GHC.IOBase.IO UTCTime, and

import Prelude()
import Data.Time.Clock(getCurrentTime) --,UTCTime)

which gives the type as GHC.IOBase.IO time-1.1.2.0:Data.Time.Clock.UTC.UTCTime.

okay, so there is a system to this. but the presence of the package prefix alone does not always imply "not in scope", does it? perhaps some way of indicating the "not in scope" aspect would be useful (putting it in braces perhaps?).

anyway, i'm changing this to a feature request. it isn't a bug, just a little odd and unexpected, and perhaps someone finds a way to make it less odd, but it isn't high priority.

thanks.

comment:3 Changed 6 years ago by igloo

  • Milestone set to _|_

comment:4 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:5 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.