Idris 中参数名称前的 0 或 1 是什么意思?

Aro*_*ron 3 idris idris2

我在 Idris 源代码中到处都看到过它,但我还没有找到它的含义的解释。我得到的最接近的是发现它RigCount语法参考中被调用。但它什么?

test : (0 a : b) -> b
test x = x
--      ^^^ Error
Run Code Online (Sandbox Code Playgroud)

当上面的例子发生时,会抛出一个错误:While processing right hand side of test. x is not accessible in this context.

将其更改为 1 会进行类型检查,但不会进一步说明其含义。

test : (1 a : b) -> b
test x = x
Run Code Online (Sandbox Code Playgroud)

242*_*684 7

这是多重性

Idris2 具有三个多重性:

  • 已擦除 ( 0) - 在运行时不可用
  • Linear ( 1) - 可以在运行时使用一次
  • 无限制(无多重标签)-可以使用任意次