Confirmation of a lazy assessment

I accidentally deleted my post, but I tried this question for clarification.

If I have a function:
const x = 1

If I ask Haskell:
const (1/0)

He will return 1, because a lazy assessment does not actually calculate what is 1/0, right? It is not necessary.

+5
source share
1 answer

Yes, it's right. const, as you defined it, will always generate 1 when evaluating it - regardless of the argument. And since the argument is not related to the result, it is not evaluated. Thus, any error or non-interruption that may be caused by the evaluation of the argument will not occur.

+8
source

All Articles