@@ -259,20 +259,20 @@ withOffset n x = Bitstream $ do
259259 put $ BitstreamState ss' (pos + pos')
260260 return r
261261
262- loc :: Bitstream Position
262+ loc :: HasCallStack => Bitstream Position
263263loc = Bitstream $ gets bssPosition
264264
265- locBytes :: Bitstream Word32
265+ locBytes :: HasCallStack => Bitstream Word32
266266locBytes = Bitstream $ gets $ fromIntegral . (`div` 8 ) . bssPosition
267267
268- locWords :: Bitstream Word32
268+ locWords :: HasCallStack => Bitstream Word32
269269locWords = Bitstream $ gets $ fromIntegral . (`div` 32 ) . bssPosition
270270
271- emitBit :: Bool -> Bitstream ()
272- emitBit True = bitstream [] (Buff 1 0b00000001 ) 1
273- emitBit False = bitstream [] (Buff 1 0b00000000 ) 1
271+ emitBit :: HasCallStack => Bool -> Bitstream ()
272+ emitBit True = bitstream [] (Buff 1 (setBit zeroBits bSize) ) 1
273+ emitBit False = bitstream [] (Buff 1 0 ) 1
274274
275- emitBits :: Int -> BType -> Bitstream ()
275+ emitBits :: HasCallStack => Int -> BType -> Bitstream ()
276276emitBits 0 _ = pure ()
277277emitBits n b | n < 8 = do
278278 -- traceM $ "emitting " ++ show n ++ " bits; value = " ++ show b
@@ -345,22 +345,22 @@ emitVBR n w = do
345345 then emitBit False
346346 else emitBit True >> emitVBR n tail
347347
348- emitChar6 :: Char -> Bitstream ()
348+ emitChar6 :: HasCallStack => Char -> Bitstream ()
349349emitChar6 ' _' = emitBits 6 63
350350emitChar6 ' .' = emitBits 6 62
351351emitChar6 c | ' a' <= c && c <= ' z' = emitBits 6 . fromIntegral $ (fromEnum c - fromEnum ' a' )
352352 | ' A' <= c && c <= ' Z' = emitBits 6 . fromIntegral $ (fromEnum c - fromEnum ' A' ) + 26
353353 | ' 0' <= c && c <= ' 9' = emitBits 6 . fromIntegral $ (fromEnum c - fromEnum ' 0' ) + 52
354354 | otherwise = fail $ " char '" ++ c: " ' not in [a-zA-Z0-9._]"
355355
356- alignWord8 :: Bitstream ()
356+ alignWord8 :: HasCallStack => Bitstream ()
357357alignWord8 = do
358358 bits <- (`mod` 8 ) <$> loc
359359 case bits of
360360 0 -> pure ()
361361 x -> emitBits (8 - x) 0
362362
363- alignWord32 :: Bitstream ()
363+ alignWord32 :: HasCallStack => Bitstream ()
364364alignWord32 = flip mod 32 <$> loc >>= \ case
365365 0 -> pure ()
366366 x | 32 - x < 8 -> emitBits (32 - x) 0
0 commit comments