mirror of
https://github.com/ilyakooo0/binary-bits.git
synced 2024-09-11 06:35:26 +03:00
Add module Bits, with BinaryBit class and instances
This commit is contained in:
parent
4b75399ed5
commit
352913f332
22
Bits.hs
Normal file
22
Bits.hs
Normal file
@ -0,0 +1,22 @@
|
||||
module Bits where
|
||||
|
||||
import BitsGet
|
||||
import BitsPut
|
||||
|
||||
import Data.Word
|
||||
|
||||
class BinaryBit a where
|
||||
putBits :: Int -> a -> BitPut ()
|
||||
getBits :: Int -> BitGet a
|
||||
|
||||
instance BinaryBit Bool where
|
||||
putBits _ = putBool
|
||||
getBits _ = getBool
|
||||
|
||||
instance BinaryBit Word8 where
|
||||
putBits = putWord8
|
||||
getBits = getWord8
|
||||
|
||||
instance BinaryBit Word16 where
|
||||
putBits = putWord16be
|
||||
getBits = getWord16be
|
@ -20,7 +20,7 @@ cabal-version: >=1.8
|
||||
|
||||
|
||||
library
|
||||
exposed-modules: BitsGet
|
||||
exposed-modules: BitsGet, BitsPut, Bits
|
||||
|
||||
build-depends: base==4.*, binary, bytestring
|
||||
-- other-modules:
|
||||
|
Loading…
Reference in New Issue
Block a user