# Pastebin xJDEEfRk untilM p m = loop where loop = do a <- m if p a then pure [a] else (a :) <$> loop getVarint = foldl' maskAndShift 0 <$> untilM endOfVarint getWord8 where maskAndShift acc byte = acc `shiftL` 7 .|. fromIntegral (clearBit byte 7) endOfVarint byte = not $ testBit byte 7