Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Binary natural numbers,
Bin
.
This module is designed to be imported qualified.
Synopsis
- data Bin
- toNatural :: Bin -> Natural
- fromNatural :: Natural -> Bin
- toNat :: Bin -> Nat
- fromNat :: Nat -> Bin
- cata :: a -> a -> (a -> a) -> (a -> a) -> Bin -> a
- data BinP
- explicitShow :: Bin -> String
- explicitShowsPrec :: Int -> Bin -> ShowS
- predP :: BinP -> Bin
- mult2 :: Bin -> Bin
- mult2Plus1 :: Bin -> BinP
- andP :: BinP -> BinP -> Bin
- xorP :: BinP -> BinP -> Bin
- complementBitP :: BinP -> Int -> Bin
- clearBitP :: BinP -> Int -> Bin
- bin0 :: Bin
- bin1 :: Bin
- bin2 :: Bin
- bin3 :: Bin
- bin4 :: Bin
- bin5 :: Bin
- bin6 :: Bin
- bin7 :: Bin
- bin8 :: Bin
- bin9 :: Bin
Binary natural numbers
Binary natural numbers.
Numbers are represented in little-endian order, the representation is unique.
>>>
mapM_ (putStrLn . explicitShow) [0 .. 7]
BZ BP BE BP (B0 BE) BP (B1 BE) BP (B0 (B0 BE)) BP (B1 (B0 BE)) BP (B0 (B1 BE)) BP (B1 (B1 BE))
Instances
Enum Bin Source # |
|
Eq Bin Source # | |
Integral Bin Source # | |
Data Bin Source # | |
Defined in Data.Bin gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> Bin -> c Bin Source # gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c Bin Source # toConstr :: Bin -> Constr Source # dataTypeOf :: Bin -> DataType Source # dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c Bin ) Source # dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c Bin ) Source # gmapT :: ( forall b. Data b => b -> b) -> Bin -> Bin Source # gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> Bin -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> Bin -> r Source # gmapQ :: ( forall d. Data d => d -> u) -> Bin -> [u] Source # gmapQi :: Int -> ( forall d. Data d => d -> u) -> Bin -> u Source # gmapM :: Monad m => ( forall d. Data d => d -> m d) -> Bin -> m Bin Source # gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> Bin -> m Bin Source # gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> Bin -> m Bin Source # |
|
Num Bin Source # |
|
Ord Bin Source # | |
Real Bin Source # | |
Show Bin Source # |
To see explicit structure, use
|
Function Bin Source # | |
Arbitrary Bin Source # | |
CoArbitrary Bin Source # | |
Bits Bin Source # | |
Defined in Data.Bin (.&.) :: Bin -> Bin -> Bin Source # (.|.) :: Bin -> Bin -> Bin Source # xor :: Bin -> Bin -> Bin Source # complement :: Bin -> Bin Source # shift :: Bin -> Int -> Bin Source # rotate :: Bin -> Int -> Bin Source # setBit :: Bin -> Int -> Bin Source # clearBit :: Bin -> Int -> Bin Source # complementBit :: Bin -> Int -> Bin Source # testBit :: Bin -> Int -> Bool Source # bitSizeMaybe :: Bin -> Maybe Int Source # bitSize :: Bin -> Int Source # isSigned :: Bin -> Bool Source # shiftL :: Bin -> Int -> Bin Source # unsafeShiftL :: Bin -> Int -> Bin Source # shiftR :: Bin -> Int -> Bin Source # unsafeShiftR :: Bin -> Int -> Bin Source # rotateL :: Bin -> Int -> Bin Source # |
|
NFData Bin Source # | |
Hashable Bin Source # | |
TestEquality SBin Source # | |
Defined in Data.Type.Bin |
fromNatural :: Natural -> Bin Source #
Positive natural numbers
Non-zero binary natural numbers.
We could have called this type
Bin1
,
but that's used as type alias for promoted
in
Data.Type.Bin
.
BP
BE
Instances
Enum BinP Source # | |
Eq BinP Source # | |
Integral BinP Source # | |
Defined in Data.BinP |
|
Data BinP Source # | |
Defined in Data.BinP gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> BinP -> c BinP Source # gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c BinP Source # toConstr :: BinP -> Constr Source # dataTypeOf :: BinP -> DataType Source # dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c BinP ) Source # dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c BinP ) Source # gmapT :: ( forall b. Data b => b -> b) -> BinP -> BinP Source # gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> BinP -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> BinP -> r Source # gmapQ :: ( forall d. Data d => d -> u) -> BinP -> [u] Source # gmapQi :: Int -> ( forall d. Data d => d -> u) -> BinP -> u Source # gmapM :: Monad m => ( forall d. Data d => d -> m d) -> BinP -> m BinP Source # gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> BinP -> m BinP Source # gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> BinP -> m BinP Source # |
|
Num BinP Source # | |
Ord BinP Source # |
|
Real BinP Source # | |
Show BinP Source # | |
Function BinP Source # | |
Arbitrary BinP Source # | |
CoArbitrary BinP Source # | |
Bits BinP Source # |
NOTE
:
|
Defined in Data.BinP (.&.) :: BinP -> BinP -> BinP Source # (.|.) :: BinP -> BinP -> BinP Source # xor :: BinP -> BinP -> BinP Source # complement :: BinP -> BinP Source # shift :: BinP -> Int -> BinP Source # rotate :: BinP -> Int -> BinP Source # setBit :: BinP -> Int -> BinP Source # clearBit :: BinP -> Int -> BinP Source # complementBit :: BinP -> Int -> BinP Source # testBit :: BinP -> Int -> Bool Source # bitSizeMaybe :: BinP -> Maybe Int Source # bitSize :: BinP -> Int Source # isSigned :: BinP -> Bool Source # shiftL :: BinP -> Int -> BinP Source # unsafeShiftL :: BinP -> Int -> BinP Source # shiftR :: BinP -> Int -> BinP Source # unsafeShiftR :: BinP -> Int -> BinP Source # rotateL :: BinP -> Int -> BinP Source # |
|
NFData BinP Source # | |
Hashable BinP Source # | |
TestEquality SBinP Source # | |
Defined in Data.Type.BinP |
Showing
explicitShow :: Bin -> String Source #
Extras
mult2Plus1 :: Bin -> BinP Source #