How to XOR two integers?

Matt Harden matth@mindspring.com
Thu, 06 Sep 2001 21:03:02 -0500


shameem@cse.iitb.ac.in wrote:
> 
> Hi,
> 
> When I have the following  program in a file test.hs:
> 
> ------------------------------------
> 
> import Int
> 
> z = xor (intToInt32 0xf32e) (intToInt32 0xac43)
> 
> ------------------------------------
> 
> The system gives the following error message:
> 
> ------------------------------------
> 
> Reading file "test.hs":
> Dependency analysis
> ERROR test.hs:5 - Undefined variable "xor"
> 
> ------------------------------------
> 
> However when I directly input the expression
> 
> Int> (xor (intToInt32 0xf32e) (intToInt32 0xac43))
> 
> I get the answer
> 
> 24429
> 
> Since Int is imported in test.hs, and Int.hs exports Int32, shouldn't
> xor be visible in test.hs?

No.  Int.hs exports Int32, but it does not export xor.  You need to
import Bits, as well as Int.