类型族强制参数有种类 *

Type family forcing parameter to have the kind *

这个简单的代码无法编译

import Data.Kind
type family F (k :: Type) :: (t :: k) -> Type

错误信息是

• Expected a type, but ‘t’ has kind ‘k’
• In the kind ‘(t :: k) -> Type’

我从某种意义上说这实际上定义了一个 "family of type families" 但我真的不明白为什么会存在这个限制。

type family F (k :: Type) (t :: k) :: Type

确实有效,但它没有相同的语义,不能相同使用。

不需要在结果类型中命名 t。你可以简单地使用

type family F (k :: Type) :: k -> Type