@@ -57,9 +57,6 @@ module Data.Binary.Bits.Get
5757
5858 BitGet
5959 , runBitGet
60− , getBitOrder
61− , selectBitOrder
62− , withBitOrder
6360
6461 -- ** Get bytes
6562 , getBool
@@ -176,10 +173,6 @@ incS o (S bs n bo) = S (unsafeDrop d bs) n' bo
176173 !d = byte_offset o'
177174 !n' = bit_offset o'
178175
179−-- | Select the bit ordering
180−selectBitOrderS :: BitOrder -> S -> S
181−selectBitOrderS bo (S bs o _) = S bs o bo
182−
183176-- | Read a single bit
184177readBool :: S -> Bool
185178readBool (S bs o bo) = case bo of
@@ -288,6 +281,15 @@ instance Applicative BitGet where
288281 pure x = return x
289282 fm <*> m = fm >>= \f -> m >>= \v -> return (f v)
290283
284+instance BitOrderable BitGet where
285+ setBitOrder bo = do
286+ (S bs o _) <- getState
287+ putState (S bs o bo)
288+
289+ getBitOrder = do
290+ (S _ _ bo) <- getState
291+ return bo
292+
291293-- | Run a 'BitGet' within the Binary packages 'Get' monad. If a byte has
292294-- been partially consumed it will be discarded once 'runBitGet' is finished.
293295runBitGet :: BitGet a -> Get a
@@ -322,13 +324,6 @@ withState f = do
322324 s <- getState
323325 putState $! f s
324326
325−-- | Get the bit ordering
326−getBitOrder :: BitGet BitOrder
327−getBitOrder = do
328− (S _ _ bo) <- getState
329− return bo
330−
331−
332327-- | Make sure there are at least @n@ bits.
333328ensureBits :: Int -> BitGet ()
334329ensureBits n = do
@@ -355,19 +350,6 @@ alignByte = do
355350 when (o /= 0) $
356351 skipBits (8-o)
357352
358−-- | Select the bit ordering
359−selectBitOrder :: BitOrder -> BitGet ()
360−selectBitOrder = withState . selectBitOrderS
361−
362−withBitOrder :: BitOrder -> BitGet a -> BitGet a
363−withBitOrder bo f = do
364− bo' <- getBitOrder
365− selectBitOrder bo
366− r <- f
367− selectBitOrder bo'
368− return r
369−
370−
371353
372354-- | Test whether all input has been consumed, i.e. there are no remaining
373355-- undecoded bytes.