bin-0.1: Bin: binary natural numbers.
Safe Haskell None
Language Haskell2010

Data.Type.BinP

Description

Positive binary natural numbers. DataKinds stuff.

Synopsis

Singleton

data SBinP (b :: BinP ) where Source #

Singleton of BinP .

Instances

Instances details
TestEquality SBinP Source #
Instance details

Defined in Data.Type.BinP

Methods

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

sbinpToNatural :: forall n. SBinP n -> Natural Source #

Convert SBinP to Natural .

>>> sbinpToNatural (sbinp :: SBinP BinP8)
8

Implicit

class SBinPI (b :: BinP ) where Source #

Let constraint solver construct SBinP .

Instances

Instances details
SBinPI ' BE Source #
Instance details

Defined in Data.Type.BinP

SBinPI b => SBinPI (' B0 b) Source #
Instance details

Defined in Data.Type.BinP

SBinPI b => SBinPI (' B1 b) Source #
Instance details

Defined in Data.Type.BinP

withSBinP :: SBinP b -> ( SBinPI b => r) -> r Source #

Construct SBinPI dictionary from SBinP .

reify :: forall r. BinP -> ( forall b. SBinPI b => Proxy b -> r) -> r Source #

Reify BinP .

reflect :: forall b proxy. SBinPI b => proxy b -> BinP Source #

Reflect type-level BinP to the term level.

reflectToNum :: forall b proxy a. ( SBinPI b, Num a) => proxy b -> a Source #

Reflect type-level BinP to the term level Num .

Type equality

Induction

induction Source #

Arguments

:: forall b f. SBinPI b
=> f ' BE

\(P(1)\)

-> ( forall bb. SBinPI bb => f bb -> f (' B0 bb))

\(\forall b. P(b) \to P(2b)\)

-> ( forall bb. SBinPI bb => f bb -> f (' B1 bb))

\(\forall b. P(b) \to P(2b + 1)\)

-> f b

Induction on BinP .

Arithmetic

Successor

type family Succ (b :: BinP ) :: BinP where ... Source #

Equations

Succ ' BE = ' B0 ' BE
Succ (' B0 n) = ' B1 n
Succ (' B1 n) = ' B0 ( Succ n)

withSucc :: forall b r. SBinPI b => Proxy b -> ( SBinPI ( Succ b) => r) -> r Source #

Addition

type family Plus (a :: BinP ) (b :: BinP ) :: BinP where ... Source #

Equations

Plus ' BE b = Succ b
Plus a ' BE = Succ a
Plus (' B0 a) (' B0 b) = ' B0 ( Plus a b)
Plus (' B1 a) (' B0 b) = ' B1 ( Plus a b)
Plus (' B0 a) (' B1 b) = ' B1 ( Plus a b)
Plus (' B1 a) (' B1 b) = ' B0 ( Succ ( Plus a b))

Conversions

To GHC Nat

type family ToGHC (b :: BinP ) :: Nat where ... Source #

type family FromGHC (n :: Nat ) :: BinP where ... Source #

Equations

FromGHC n = FromGHC' (FromGHCMaybe n)

To fin Nat

Aliases