5 ms·
Shouldn't the then- and else-"branches" be made lazy?
by Dewie 12y ago
Shouldn't the then- and else-"branches" be made lazy?
- eru 12y agoThey probably are already. (In Haskell, they would be by default. I don't know enough about Agda.)
- andolanra 12y agoThat is indeed the case. In Agda, the default is call-by-name, which means that functions are applied before arguments are evaluated. This does not, however, include sharing, so evaluating (λ x → x + x) (fib 2000) will evaluate `fib 2000` twice. Agda programs can also be compiled to Haskell, in which case they would have Haskell's evaluation strategy, which is generally call-by-need (and so would share the result of fib 2000 above.)
- tel 12y agoI've never been aware of whether Agda is CBN or CBV because it actually doesn't matter (!). In a pure, terminating language like Agda evaluation is "confluent" which means that CBV and CBN evaluations are identical.
- Dewie 12y agoHuh, for some reason I assumed that we were talking about Idris. I didn't read the post well enough.