Open Rufflewind opened 9 years ago
Makes a lot of sense to me. #365 describes a very similar issue.
Here's another example where this would be helpful: The last setEnv is actually from a different module which makes the rendered haddocks very confusing.
Maybe a heuristic like: if an entity exported from this module has the same name as the linked one use the fully qualified name?
Maybe a heuristic like: if an entity exported from this module has the same name as the linked one use the fully qualified name?
We'd also want to distinguish between different non-local identifiers of the same name, such as lazy and strict ByteString
.
But, yeah, I think that's a nice idea. It could be implemented as a new --qual
mode for a start.
--qual=disambiguate
or -q unique
maybe?
Here's another example where this would be helpful: The last setEnv is actually from a different module which makes the rendered haddocks very confusing.
BTW note that --qual=*
currently wouldn't help with this case. --qual
works only for identifiers in scope: https://github.com/haskell/haddock/issues/990#issuecomment-451310235
@sjakobi do you know where the disambiguation could take place?
Edit: it seems the backends are in haddock-api.
do you know where the disambiguation could take place?
The qualification happens here:
We'd want to extend this function:
I'm not sure where exactly to decide which identifiers need to be qualified. It's possible that Hi Haddock will make it easier though.
I have another rendered example that makes it look like Haskell has recursive type synonyms;
type TcPlugin = [CommandLineOption] -> Maybe TcPlugin
.
I was like, no really when did we get recursive type synonyms? I spent about 15 mins trying to find out but then I looked at the source and saw it wasn't so.
-- GHC/Driver/Plugins.hs
type TcPlugin = [CommandLineOption] -> Maybe GHC.Tc.Types.TcPlugin
With this ambiguity in haddock rendering we could be confusing and frustrating people who are trying to get things done, people that are trying to learn the language or people digging in to see how a library works.
There is a tendency in Haskell to use the same name for different things, e.g.
ByteString
for both the lazy and strict versions. Haddock doesn't cope with these very well, so you end up with confusing type signatures like:It would be much clearer if the former were partly qualified since it originates from outside the current module:
The
--qual
flag, while it works for this case, seems to qualify nearly all the names and adding a considerable amount of verbosity to the docs. Instead, I think Haddock should only qualify names that would otherwise be ambiguous, and preferably on by default since Hackage uses only default settings.