bin-0.1.1: Bin: binary natural numbers.
Safe HaskellSafe
LanguageHaskell2010

Data.BinP

Description

Positive binary natural numbers, BinP.

This module is designed to be imported qualified.

Synopsis

Documentation

data BinP Source #

Non-zero binary natural numbers.

We could have called this type Bin1, but that's used as type alias for promoted BP BE in Data.Type.Bin.

Constructors

BE

one

B0 BinP

mult2

B1 BinP

mult2 plus 1

Instances

Instances details
Enum BinP Source # 
Instance details

Defined in Data.BinP

Methods

succ :: BinP -> BinP #

pred :: BinP -> BinP #

toEnum :: Int -> BinP #

fromEnum :: BinP -> Int #

enumFrom :: BinP -> [BinP] #

enumFromThen :: BinP -> BinP -> [BinP] #

enumFromTo :: BinP -> BinP -> [BinP] #

enumFromThenTo :: BinP -> BinP -> BinP -> [BinP] #

Eq BinP Source # 
Instance details

Defined in Data.BinP

Methods

(==) :: BinP -> BinP -> Bool #

(/=) :: BinP -> BinP -> Bool #

Integral BinP Source # 
Instance details

Defined in Data.BinP

Methods

quot :: BinP -> BinP -> BinP #

rem :: BinP -> BinP -> BinP #

div :: BinP -> BinP -> BinP #

mod :: BinP -> BinP -> BinP #

quotRem :: BinP -> BinP -> (BinP, BinP) #

divMod :: BinP -> BinP -> (BinP, BinP) #

toInteger :: BinP -> Integer #

Data BinP Source # 
Instance details

Defined in Data.BinP

Methods

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 #

toConstr :: BinP -> Constr #

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 :: forall r r'. (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 # 
Instance details

Defined in Data.BinP

Methods

(+) :: BinP -> BinP -> BinP #

(-) :: BinP -> BinP -> BinP #

(*) :: BinP -> BinP -> BinP #

negate :: BinP -> BinP #

abs :: BinP -> BinP #

signum :: BinP -> BinP #

fromInteger :: Integer -> BinP #

Ord BinP Source #
>>> sort [ 1 .. 9 :: BinP ]
[1,2,3,4,5,6,7,8,9]
>>> sort $ reverse [ 1 .. 9 :: BinP ]
[1,2,3,4,5,6,7,8,9]
>>> sort $ [ 1 .. 9 ] ++ [ 1 .. 9 :: BinP ]
[1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9]
Instance details

Defined in Data.BinP

Methods

compare :: BinP -> BinP -> Ordering #

(<) :: BinP -> BinP -> Bool #

(<=) :: BinP -> BinP -> Bool #

(>) :: BinP -> BinP -> Bool #

(>=) :: BinP -> BinP -> Bool #

max :: BinP -> BinP -> BinP #

min :: BinP -> BinP -> BinP #

Real BinP Source # 
Instance details

Defined in Data.BinP

Methods

toRational :: BinP -> Rational #

Show BinP Source # 
Instance details

Defined in Data.BinP

Methods

showsPrec :: Int -> BinP -> ShowS #

show :: BinP -> String #

showList :: [BinP] -> ShowS #

Function BinP Source # 
Instance details

Defined in Data.BinP

Methods

function :: (BinP -> b) -> BinP :-> b #

Arbitrary BinP Source # 
Instance details

Defined in Data.BinP

Methods

arbitrary :: Gen BinP #

shrink :: BinP -> [BinP] #

CoArbitrary BinP Source # 
Instance details

Defined in Data.BinP

Methods

coarbitrary :: BinP -> Gen b -> Gen b #

Bits BinP Source #

NOTE: .&., xor, shiftR and rotateR are __NOT_ implemented. They may make number zero.

Instance details

Defined in Data.BinP

NFData BinP Source # 
Instance details

Defined in Data.BinP

Methods

rnf :: BinP -> () #

Hashable BinP Source # 
Instance details

Defined in Data.BinP

Methods

hashWithSalt :: Int -> BinP -> Int #

hash :: BinP -> Int #

TestEquality SBinP Source # 
Instance details

Defined in Data.Type.BinP

Methods

testEquality :: forall (a :: k) (b :: k). SBinP a -> SBinP b -> Maybe (a :~: b) #

Conversions

cata Source #

Arguments

:: a

\(1\)

-> (a -> a)

\(2x\)

-> (a -> a)

\(2x + 1\)

-> BinP 
-> a 

Fold BinP.

fromNatural :: Natural -> BinP Source #

fromNatural for BinP.

Throws when given 0.

toNat :: BinP -> Nat Source #

Convert from BinP to Nat.

Showing

explicitShow :: BinP -> String Source #

show displaying a structure of BinP.

>>> explicitShow 11
"B1 (B1 (B0 BE))"

explicitShowsPrec :: Int -> BinP -> ShowS Source #

showsPrec displaying a structure of BinP.

Extras

Aliases