*(星号)或其他类型在 haddock 的实例列表中是什么意思

What does * (star) or other kinds mean in an instance list of haddock

浏览各种包的黑线鳕我经常遇到这样的实例文​​档(Control.Category):

Category k (Coercion k)
Category * (->)

或这个 (Control.Monad.Trans.Identity):

MonadTrans (IdentityT *)

这里的kind签名到底是什么意思?它没有出现在源代码中,但我已经注意到它似乎出现在使用 PolyKinds 扩展名的模块中。我怀疑它可能像一个 TypeApplication 但有一种。所以例如最后一个例子意味着 IdentityT 是一个单子变换器,如果它的第一个参数有种类 *.

所以我的问题是:

我不是要各种解释。

To quote Richard Eisenberg’s recent post on the haskell-cafe mailing list:

Haddock struggles sometimes to render types with -XPolyKinds enabled. The problem is that GHC generally does not require kind arguments to be written and it does not print them out (unless you say -fprint-explicit-kinds). But Haddock, I believe, prints out kinds whenever -XPolyKinds is on. So the two different definitions are really the same: it's just that one module has -XPolyKinds and the other doesn't.

The * is the kind of ordinary types. So Int has kind * (we write Int :: *) while Maybe has kind * -> *. Typeable actually has kind forall k. k -> Constraint, meaning that it's polykinded. In the first snippet below, the * argument to Typeable instantiates k with *, because type variable a has kind *.

所以是的,如您所料,它与 PolyKinds 有关。 Haddock 使用一种“显式应用程序”呈现这些 poly-kinded 类型。 Category 恰好是 poly-kinded,具有类型 forall k. (k -> k -> *) -> Constraint,因此 Haddock 在每个实例旁边呈现类型应用程序。

在我看来,这是 Haddock 的错误或功能不当,因为据我所知没有等效的源代码模拟。它令人困惑,而且我不知道有什么更好的方法来理解它,而不是识别它通常表现出来的方式,并从上下文中直观地推断出发生了什么。