类型的名称 - 为什么?

The name of a type - why?

谁能给我解释一下:

singleton : (t : Type) -> t -> HList [t]

这里为什么要用"t"? t 是否引用类型 Type 实例

但为什么不仅仅这样做:

singleton : Type -> Type -> HList [Type]
singleton : (t : Type) -> t -> HList [t]

接受两个参数——一个类型和一个该类型的值,例如

singleton Int 3 : HList [Int]
singleton String "string" : HList [String]

相比之下

singleton : Type -> Type -> HList [Type]

需要两个 Type 参数,例如

singleton Int String

但是假设你定义了一个 HList 它可能被定义为:

data HList : List Type -> Type where
  Nil : HList []
  singleton : (t : Type) -> t -> HList [t]
  ...

所以它需要通过索引值的类型列表进行参数化。您的 singleton 构造函数将无效,因为 Type 不是 Type 类型的值。