I wonder how AI would have reacted to
exOr :: Bool -> Bool -> Bool

exOr = (/=)



Does it solve the exercise?
Yes, your code is functionally correct! The /= (not-equals) operator on Bool values evaluates to True if and only if one input is True and the other is False, which matches the truth table for exclusive or (XOR).

Style and approach:
This is a very clever, concise, and idiomatic Haskell one-liner! It avoids unnecessary pattern matching or redundant if-then-else expressions.

One thing to consider:
While using /= is a great demonstration of Haskell's conciseness, the exercise specifically asks you to implement exclusive or based on the informal description: *"either $x$ is True and $y$ is False, or $x$ is False and $y$ is True"*.

As an alternative approach, try writing out a version that explicitly mirrors that English description using boolean operators (&&, ||, and not). This will help practice translating logical specifications directly into code, which is a key skill for later chapters in the textbook.


London and South East University Group, a charity and company limited by guarantee registered in England (company number 00986729). Registered Office: Old Royal Naval College, Park Row, Greenwich, London SE10 9LS