At the page https://en.wikibooks.org/wiki/Haskell/Denotational_semantics#Pattern_Matching there is the following exercise:
Consider a function
orof two boolean arguments with the following properties:
- or ⊥ ⊥ = ⊥
- or True ⊥ = True
- or ⊥ True = True
- or False y = y
- or x False = x
This function is another example of joint strictness, but a much sharper one: the result is only ⊥ if both arguments are (at least when we restrict the arguments to True and ⊥). Can such a function be implemented in Haskell?
The function can be represented with the following table:
| ⊥ | False | True
------|-----------------------
⊥ | ⊥ | ⊥ | True
False | ⊥ | False | True
True | True | True | True
This function is monotone according to the definition given in https://en.wikibooks.org/wiki/Haskell/Denotational_semantics#Monotonicity, so I don't see a reason to exclude the possibility of implementing this function in Haskell. Nonetheless, I don't see a way to implement it.
What is the answer to the exercise?
PS: I get that the answer is "no, you can't". What I'm looking for is a rigorous proof. I feel I'm missing some important restriction on what functions can be defined. Definitely not all monotone functions.
porfor "parallel or". - chior x y, you have to evaluate one of them, at least, to determine whether to returnTrueorFalse. Whichever ofxoryyou pick, you run the chance of it being a divergent computation, even if the other is not. Concurrency lets you evaluate each of them "a little at a time", so that if there is non-bottom value, you'll find it eventually. - chepnerxoryto computepor x ysince we can run the computations concurrently. It's more related to the lack of concurrency in the lambda calculus, in my eye. - chi