alexwl / haskell-code-explorer

Web application for exploring and understanding Haskell codebases
MIT License
509 stars 20 forks source link

Enhancement: Kind of type parameter on hover #19

Open langston-barrett opened 5 years ago

langston-barrett commented 5 years ago

Could the code viewer perhaps show the inferred kind of a type parameter on hover, perhaps with a similar UI to type-on-hover? e.g. it might show Type or * when hovering over a in the following declaration (on either the LHS or RHS):

newtype Foo a = MkFoo a
alexwl commented 5 years ago

HCE does show kinds of type variables, but unfortunately, not always.

For example, here https://haskell-code-explorer.mfix.io/package/base-4.11.1.0/show/Data/Functor/Sum.hs#L33 kinds of type variables are shown:

data Sum f g a = InL (f a) | InR (g a)
f :: k -> *
g :: k -> *
a :: k

haskell-code-indexer gets kinds of type constructors and type variables from the type environment (a map from Name to TyThing created by the GHC) of a module. Type constructors are always in the type environment, type variables, however, sometimes are omitted from the type environment. As far as I understand, it depends on whether the value constructor, e.g., MkFoo, is used (not just declared) somewhere in the current module.