commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.95k stars 842 forks source link

Improve error message for multiple matching packages for "stack script" #3823

Open mgsloan opened 6 years ago

mgsloan commented 6 years ago

Current error message if you run stack script on a file with import Text.Mustache is

Module Text.Mustache appears in multiple packages: mustache stache
Called from:
  throwString (src/Stack/Script.hs:151:41 in stack-1.6.0-8X4wAceLUOM24tZpnp4UV1:Stack.Script)

Ideally this should give the following info:

pbrinkmeier commented 3 years ago

Hi, I use Stack's script feature a lot myself and I'd like to fix this as my first Stack issue.

I'd start by changing the error message in https://github.com/commercialhaskell/stack/blob/master/src/Stack/Script.hs#L58. In order to do that, I'd change the exception type in https://github.com/commercialhaskell/stack/blob/master/src/Stack/Script.hs#L49 to something like:

AmbiguousModuleName ModuleName [PackageName] [PackageName]

where the newly introduced field contains the name of inferred packages.

Does this seem reasonable?