You need the correct instance for Int . This is a built-in type, and you cannot expect magic here. Providing an empty instance for Int will lead to a loop (this may be a bad design decision, but the way it is now).
Here's the one that works (but by no means effective):
import Data.Bits boolToBit :: Bool -> Bit boolToBit False = O boolToBit True = I instance Serialize Int where put x = map (boolToBit . testBit x) [0 .. bitSize x - 1]
If you really need a minimal example, then do not use Int , use Tree () or Tree Bool instead.
source share