Closed runeksvendsen closed 4 months ago
Neither of these is perfect, but a rule of thumb is that if something is a re-export from some other package it will not have a "source" link, while haddocks within a package will have a source link. Further, one can open the instance of datatypes, should any instances be defined, and note those instances are defined in base
which likely means the datatype itself is also defined there.
Neither of these is perfect, but a rule of thumb is that if something is a re-export from some other package it will not have a "source" link, while haddocks within a package will have a source link.
I should probably have noted that I'm interested in not just determining whether or not something is a re-export, but also what it is a re-export of — ie. in which module it was originally defined.
In essence, I'm looking for the ability to construct a set of "equivalent types", where all members of this set are considered "the same type" by GHC when doing type checking. For the IO
type this would include (but not necessarily be limited to) the following fully qualified identifiers:
Notably, this set includes both the newtype GHC.Types.IO
and the data type Prelude.IO
(which GHC apparently considers equivalent). I wonder if GHC is somehow hardcoded to consider these two (seemingly distinct, since one is newtype IO a
and the other is data IO a
) types as equivalent.
Further, one can open the instance of datatypes, should any instances be defined, and note those instances are defined in
base
which likely means the datatype itself is also defined there.
This seems very promising. However, when I open the Haddocks for e.g. Hedgehog.Internal.Prelude.IO there are no "Source" links for any of the instance declarations. Is this because it's a re-export?
Right. That's what I said above. "if something is a re-export from some other package it will not have a "source" link, while haddocks within a package will have a source link."
Note if you click to open the instances you can see where those are defined.
Hi, thank you for this ticket, but Haddock now lives full-time in the GHC repository! Read more at https://discourse.haskell.org/t/haddock-now-lives-in-the-ghc-repository/9576.
Let me know if you feel it is still needed, and I'll migrate it. :)
I asked the below question in the Haskell subreddit and did not find a solution. Therefore I'm asking the same question here. Also, if the answer (as I expect) is "it's not possible", I hope someone can give an overview of the changes required to make it possible.
I'm trying to figure out whether it's possible to tell from Haddock documentation whether a given data type is a distinct type with the same name or a re-export of a type defined in another module.
For example, if I search for
IO
on Hoogle, the result fordata IO a
points to many different modules, e.g. theHedgehog.Internal.Prelude
module from thehedgehog
package: https://hackage.haskell.org/package/hedgehog-1.2/docs/Hedgehog-Internal-Prelude.html#t:IO. As far as I can see, there is no way to tell, from the docs alone, that this type is a re-export ofPrelude.IO
. However, this must be the case since the following code typechecks:If I, on the other hand, search for e.g.
Query
on Hoogle, I will get lots of data types calledQuery
that are not the same, ie. not re-exports. For example:Which means that the following will not typecheck:
Hence my question: given the Haddocks for two datatypes with the same name, is there a way to tell if they're the same?