putBigint putter value = do
  putter len  -- TODO: verify size?
  if value < 0
    then put8u 1
    else put8u 0
  putL $ B.pack $ map (fromIntegral . digit) [0..len-1]
  where
    value'    = abs value
    len       = ceiling $ logBase 256 (fromIntegral $ value' + 1)
    digit pos = (value' `shiftR` (8 * pos)) .&. 0xFF
putBigint putter value = do
  putter len  -- TODO: verify size?
  if value < 0
    then put8u 1
    else put8u 0
  putL $ B.pack $ map (fromIntegral . digit) [0..len-1]
  where
    value'    = abs value
    len       = ceiling $ logBase 256 (fromIntegral $ value' + 1)
    digit pos = (value' `shiftR` (8 * pos)) .&. 0xFF
putBigint putter value = do
  putter len  -- TODO: verify size?
  if value < 0
    then put8u 1
    else put8u 0
  putL $ B.pack $ map (fromIntegral . digit) [0..len-1]
  where
    value'    = abs value
    len       = ceiling $ logBase 256 (fromIntegral $ value' + 1)
    digit pos = (value' `shiftR` (8 * pos)) .&. 0xFF