Exercises part 2
-
Define a wrapper record for integral values and implement
Monoid
so that(<+>)
corresponds to(.&.)
.Hint: Have a look at the functions available from interface
Bits
to find a value suitable as the neutral element. -
Define a wrapper record for integral values and implement
Monoid
so that(<+>)
corresponds to(.|.)
. -
Use bitwise operations to implement a function, which tests if a given value of type
Bits64
is even or not. -
Convert a value of type
Bits64
to a string in binary representation. -
Convert a value of type
Bits64
to a string in hexadecimal representation.Hint: Use
shiftR
and(.&. 15)
to access subsequent packages of four bits.