How do I use Bits type in Haskell?

162 Views Asked by At

I am using WinHugs98 and I would like to do simple XOR of Int 10 with Int 11.

How do I do it?

Current Attempt:

Hugs> :l Data.Bits
Data.Bits> (Bits 10) `xor` (Bits 11)
ERROR - Undefined data constructor "Bits"

How do I convert the integer 10 and 11 to a "Bits" type so it can be used? Then I want to convert back to print on screen.

Edit for Louise Wasserman:

enter image description here

1

There are 1 best solutions below

6
Louis Wasserman On

There is no conversion to be done. Int is an instance of the Bits class, meaning the methods from Bits are defined for Int. Just use xor directly:

10 `xor` 11