X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=wavpack.git;a=blobdiff_plain;f=Codec%2FAudio%2FWavPack%2FBitString.hs;h=577e09f220114a978619cf2b40bffc945e03cdf5;hp=11302768c4ba9a5b7a06f7eafada9bdc27296515;hb=16211cdd0d7ebd32f10e224ab11bebc8be6fecb5;hpb=edbf72e428c87aa6ef2dc7414baa2ac9378fd29f diff --git a/Codec/Audio/WavPack/BitString.hs b/Codec/Audio/WavPack/BitString.hs index 1130276..577e09f 100644 --- a/Codec/Audio/WavPack/BitString.hs +++ b/Codec/Audio/WavPack/BitString.hs @@ -52,6 +52,8 @@ data BitString } deriving Show +-- | /O(n)/ The bitstrings must have finite lengths to test the +-- equality. instance Eq BitString where a == b = leftRem a' ≡ leftRem b' ∧ leftBytes a' ≡ leftBytes b' ∧ @@ -289,7 +291,8 @@ null bs ∧ remNull (rightRem bs) --- | /O(n)/ Return the number of bits in a 'BitString'. +-- | /O(n)/ @'length' bs@ returns the number of bits in @bs@. @bs@ +-- must have a finite length. length ∷ Integral n ⇒ BitString → n length bs = fromIntegral $ ( fromIntegral (remLen $ leftRem bs) @@ -311,16 +314,18 @@ fromByteString bs = BitString { , rightRem = remEmpty } --- | /O(n)/ Convert a 'BitString' into 'L.ByteString', padding --- incomplete bytes to single bytes with necessary 0's at their --- MSB. Thus the following equation does not hold when the length of --- 'BitString' isn't multiple of 8. +-- | /O(n)/ @'toByteString' bs@ converts @bs@ into 'L.ByteString', +-- padding incomplete bytes to single bytes with necessary 0's at +-- their MSB. Thus the following equation does not hold when the +-- length of @bs@ isn't multiple of 8. -- -- > fromByteString . toByteString = id -- -- But the following always holds true. -- -- > toByteString . fromByteString = id +-- +-- Note that @bs@ must have a finite length. toByteString ∷ BitString → L.ByteString toByteString bs = L.concat [ remToStr $ leftRem bs