Safe Haskell | Safe |
---|---|
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 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Bin # dataTypeOf :: Bin -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Bin) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Bin) # gmapT :: (forall b. Data b => b -> b) -> Bin -> Bin # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Bin -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Bin -> r # gmapQ :: (forall d. Data d => d -> u) -> Bin -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Bin -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Bin -> m Bin # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Bin -> m Bin # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Bin -> m Bin # | |
Num Bin Source # |
|
Ord Bin Source # | |
Real Bin Source # | |
Defined in Data.Bin toRational :: Bin -> Rational # | |
Show Bin Source # | To see explicit structure, use |
Function Bin Source # | |
Arbitrary Bin Source # | |
CoArbitrary Bin Source # | |
Bits Bin Source # | |
Defined in Data.Bin | |
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 # | |
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 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BinP # dataTypeOf :: BinP -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BinP) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BinP) # gmapT :: (forall b. Data b => b -> b) -> BinP -> BinP # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BinP -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BinP -> r # gmapQ :: (forall d. Data d => d -> u) -> BinP -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> BinP -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> BinP -> m BinP # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BinP -> m BinP # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BinP -> m BinP # | |
Num BinP Source # | |
Ord BinP Source # |
|
Real BinP Source # | |
Defined in Data.BinP toRational :: BinP -> Rational # | |
Show BinP Source # | |
Function BinP Source # | |
Arbitrary BinP Source # | |
CoArbitrary BinP Source # | |
Bits BinP Source # | NOTE: |
Defined in Data.BinP (.&.) :: BinP -> BinP -> BinP # (.|.) :: BinP -> BinP -> BinP # complement :: BinP -> BinP # shift :: BinP -> Int -> BinP # rotate :: BinP -> Int -> BinP # setBit :: BinP -> Int -> BinP # clearBit :: BinP -> Int -> BinP # complementBit :: BinP -> Int -> BinP # testBit :: BinP -> Int -> Bool # bitSizeMaybe :: BinP -> Maybe Int # shiftL :: BinP -> Int -> BinP # unsafeShiftL :: BinP -> Int -> BinP # shiftR :: BinP -> Int -> BinP # unsafeShiftR :: BinP -> Int -> BinP # rotateL :: BinP -> Int -> BinP # | |
NFData BinP Source # | |
Hashable BinP Source # | |
TestEquality SBinP Source # | |
Defined in Data.Type.BinP |
Showing
explicitShow :: Bin -> String Source #
Extras
mult2Plus1 :: Bin -> BinP Source #