Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
.cabal-sandbox
dist
dist-*
cabal-dev
*.o
*.hi
*.hie
*.chi
*.chs.h
*.dyn_o
*.dyn_hi
.hpc
.hsenv
.cabal-sandbox/
cabal.sandbox.config
dist/
*.prof
*.aux
*.hp
*.eventlog
.stack-work/
cabal.project.local
cabal.project.local~
.HTF/
.ghc.environment.*
16 changes: 9 additions & 7 deletions Data/Binary/Bits/Get.hs
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,12 @@ newtype BitGet a = B { runState :: S -> Get (S,a) }

instance Monad BitGet where
return x = B $ \s -> return (s,x)
fail str = B $ \(S inp n) -> putBackState inp n >> fail str
(B f) >>= g = B $ \s -> do (s',a) <- f s
runState (g a) s'

instance MonadFail BitGet where
fail str = B $ \(S inp n) -> putBackState inp n >> fail str

instance Functor BitGet where
fmap f m = m >>= \a -> return (f a)

Expand Down Expand Up @@ -467,13 +469,13 @@ shiftl_w32 :: Word32 -> Int -> Word32
shiftl_w64 :: Word64 -> Int -> Word64

#if defined(__GLASGOW_HASKELL__) && !defined(__HADDOCK__)
shiftl_w8 (W8# w) (I# i) = W8# (w `uncheckedShiftL#` i)
shiftl_w16 (W16# w) (I# i) = W16# (w `uncheckedShiftL#` i)
shiftl_w32 (W32# w) (I# i) = W32# (w `uncheckedShiftL#` i)
shiftl_w8 (W8# w) (I# i) = W8# (wordToWord8# (word8ToWord# w `uncheckedShiftL#` i))
shiftl_w16 (W16# w) (I# i) = W16# (wordToWord16# (word16ToWord# w `uncheckedShiftL#` i))
shiftl_w32 (W32# w) (I# i) = W32# (wordToWord32# (word32ToWord# w `uncheckedShiftL#` i))

shiftr_w8 (W8# w) (I# i) = W8# (w `uncheckedShiftRL#` i)
shiftr_w16 (W16# w) (I# i) = W16# (w `uncheckedShiftRL#` i)
shiftr_w32 (W32# w) (I# i) = W32# (w `uncheckedShiftRL#` i)
shiftr_w8 (W8# w) (I# i) = W8# (wordToWord8# (word8ToWord# w `uncheckedShiftRL#` i))
shiftr_w16 (W16# w) (I# i) = W16# (wordToWord16# (word16ToWord# w `uncheckedShiftRL#` i))
shiftr_w32 (W32# w) (I# i) = W32# (wordToWord32# (word32ToWord# w `uncheckedShiftRL#` i))


#if WORD_SIZE_IN_BITS < 64
Expand Down
2 changes: 1 addition & 1 deletion Data/Binary/Bits/Put.hs
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,4 @@ instance Monad BitPut where
let PairS a s' = run m s
PairS b s'' = run (k a) s'
in PairS b s''
return x = BitPut $ \s -> PairS x s
return = pure
5 changes: 1 addition & 4 deletions binary-bits.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ build-type: Simple

cabal-version: >=1.10

source-repository head
type: git
location: git://github.com/kolmodin/binary-bits.git

library
build-depends: base==4.*, binary >= 0.6.0.0, bytestring
build-depends: base >=4.17.2.1, binary >= 0.6.0.0, bytestring

other-extensions: RankNTypes, MagicHash, BangPatterns, CPP

Expand Down