Idris 中向量的类型检查

Type checking for Vectors in Idris

REPL 如何不确保列表确实被解释为向量?

例如,如果我输入:

:t Vect

我得到 Vect : Nat -> Type -> Type 如果我输入

这绝对有意义
:t Vect 2

我得到 Vect : Type -> Type 这又是绝对有道理的。但我现在试试:

:t Vect 2 [1,2]

并得到一个错误

Can't disambiguate since no name has a suitable type: 
         Prelude.List.::, Prelude.Stream.::, Data.Vect.::

我希望看到 [1,2] : Vect 2 Int。我做错了什么?我在尝试将列表解释为向量时使用函数 the 时也遇到问题。

有什么建议吗?

the : (a : Type) -> a -> a 采用类型和该类型的值以及 returns 该值。因此,如果无法从上下文中推断出目标类型,就像在 REPL 中一样,您可以使用 the (Vect 2 Int) [1,2] 来指定 [1,2].

的含义

(Vect 2 [1,2] 尝试使用 ListStreamVect [1,2] 作为 Vect 2 : Type -> Type 中的参数。但不同于例如Int,列表 [1,2] 不是 Type,因此会抛出该错误。)