Open crockeea opened 5 years ago
With original code
λ> B.unpack $ (B.pack [0xFF, 0, 0, 0]) `shiftR` 8
[0,0,0,0]
After your update buffer becomes shorter
λ> B.unpack $ (B.pack [0xFF, 0, 0, 0]) `shiftR` 8
[0,255]
So finally it should become something like this
shiftR bs i
| i `mod` 8 == 0 =
B.take (B.length bs) $ B.replicate (i `div` 8) 0 <> B.take (i `div` 8) bs <> B.drop (i `div` 8) bs
...
should be