I accidentally deleted my post, but I'm reposting this question for clarification.
If I have a function:const x = 1
If I ask Haskell:const (1/0)
It will return 1
because lazy evaluation doesn't actually calculate what 1/0
is, right? It doesn't need to.
Yes, that's right. const
, as you defined it, will always produce 1 when it is evaluated - no matter what the argument is. And since the argument is not relevant to the result, it is not evaluated. Thus any error or non-termination that might be caused by evaluating the argument will not occur.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With