Idris 如何知道在哪里插入 Force 和 Delay?

How does Idris know where to insert Force and Delay?

根据 Idris crash course:

The Idris type checker knows about the Lazy type, and inserts conversions where necessary between Lazy a and a, and vice versa.

例如b1 && b2转换为b1 && Delay b2。 Idris 在决定在哪里放置这些隐式转换时使用的具体规则是什么?

IIRC 它只是基于提供类型和预期类型的​​统一。 (&&) 的类型为 Bool -> Lazy Bool -> Bool。将第二个参数与 y: Bool 统一将其转换为 (delay y) 值。另一方面,如果您将 x : Lazy Bool 作为第一个参数传递,它会转换为 (force x)。这将对任何具有 Lazy a 类型的 values/function 完成。