Ticket #837 (closed feature request: wontfix)

Opened 7 years ago

Last modified 5 years ago

Infer fully qualified names to overcome namespace clashes

Reported by: p.tanski@… Owned by: nobody
Priority: normal Milestone:
Component: Compiler Version: 6.4.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

If you could interpret Section 5.5.2 of the last published Haskell Report (1998) as meaning: "[i]t is not an error for there to exist names [such as A.f or f] that cannot be ... resolved [by the implementation] ..." Then it would be exceptionally handy for GHC to be able to infer what any human being can infer from most name usage in a function. For example:

import Data.Map import Data.List

runThroughMap :: (Ord k) => Map k a -> Map k b runThroughMap m = map f m

runThroughList :: [a] -> [b] runThroughList l = map g l

GHC will produce an error that this "map" is an ambiguous reference and provides a nice error message containing the fully qualified names. If you accept a permissive interpretation of Section 5.5.2 of the '98 Report, GHC could infer from context that map in runThroughMap is being used on a Map and therefore should be fully qualifiable and unambiguous; similarly for map used in runThroughList.

Of course, if you disagree with this interpretation for whatever reason--many reasons are practical--feel free to delete this feature request...

W.B.R.

-Peter T.

Change History

Changed 7 years ago by simonpj

  • status changed from new to closed
  • resolution set to wontfix

Java decides which variable you mean by looking at the types of its arguments. Thus, if x::C and y::D, the calls f(x) and f(y) may call entirely different functions.

That works well when the type of every variable is declared. It does not work at all when the type of most variables is inferred.

So Haskell does not use type clues to decide which 'f' you mean. Instead, it uses type classes.

You might find  Object-oriented overloading for Haskell interesting.

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

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