on master help sign in
Add module Bits, with BinaryBit class and instances
commit352913f332cccd23f47c4221afe006fe0efc2226 authorLennart Kolmodin <kolmodin@gentoo.org> dateThu 26 Aug 2010, 18:40 (16 years ago) parent4b75399
2 files changed+23−1
Bits.hs+22 binary-bits.cabal+1−1
Bits.hsnew file+22
@@ -0,0 +1,22 @@
1+module Bits where
2+
3+import BitsGet
4+import BitsPut
5+
6+import Data.Word
7+
8+class BinaryBit a where
9+ putBits :: Int -> a -> BitPut ()
10+ getBits :: Int -> BitGet a
11+
12+instance BinaryBit Bool where
13+ putBits _ = putBool
14+ getBits _ = getBool
15+
16+instance BinaryBit Word8 where
17+ putBits = putWord8
18+ getBits = getWord8
19+
20+instance BinaryBit Word16 where
21+ putBits = putWord16be
22+ getBits = getWord16be
binary-bits.cabal+1−1
@@ -20,7 +20,7 @@ cabal-version: >=1.8
2020
2121
2222library
23− exposed-modules: BitsGet
23+ exposed-modules: BitsGet, BitsPut, Bits
2424
2525 build-depends: base==4.*, binary, bytestring
2626 -- other-modules: