ersatz-0.3: A monad for expressing SAT or QSAT problems using observable sharing.

Copyright© Edward Kmett 2010-2015, © Eric Mertens 2014, Johan Kiviniemi 2013
LicenseBSD3
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe
LanguageHaskell2010

Ersatz.Bits

Contents

Description

Bits is an arbitrary length natural number type

Synopsis

Fixed length bit vectors

newtype Bit1 Source

A container of 1 Bit that encodes from and decodes to Word8

Constructors

Bit1 Bit 

data Bit2 Source

A container of 2 Bits that encodes from and decodes to Word8

Constructors

Bit2 !Bit !Bit 

data Bit3 Source

A container of 3 Bits that encodes from and decodes to Word8

Constructors

Bit3 !Bit !Bit !Bit 

data Bit4 Source

A container of 4 Bits that encodes from and decodes to Word8

Constructors

Bit4 !Bit !Bit !Bit !Bit 

data Bit5 Source

A container of 5 Bits that encodes from and decodes to Word8

Constructors

Bit5 !Bit !Bit !Bit !Bit !Bit 

data Bit6 Source

A container of 6 Bits that encodes from and decodes to Word8

Constructors

Bit6 !Bit !Bit !Bit !Bit !Bit !Bit 

data Bit7 Source

A container of 7 Bits that encodes from and decodes to Word8

Constructors

Bit7 !Bit !Bit !Bit !Bit !Bit !Bit !Bit 

data Bit8 Source

A container of 8 Bits that encodes from and decodes to Word8

Constructors

Bit8 !Bit !Bit !Bit !Bit !Bit !Bit !Bit !Bit 

Variable length bit vectors

class HasBits a where Source

HasBits provides the bits method for embedding fixed with numeric encoding types into the arbitrary width Bits type.

Methods

bits :: a -> Bits Source

isEven :: HasBits b => b -> Bit Source

Predicate for even-valued Bitss.

isOdd :: HasBits b => b -> Bit Source

Predicate for odd-valued Bitss.

sumBit :: Foldable t => t Bit -> Bits Source

Optimization of sumBits enabled when summing individual Bits.

sumBits :: (Foldable t, HasBits a) => t a -> Bits Source

Compute the sum of a source of Bits values.

Adders

fullAdder Source

Arguments

:: Bit 
-> Bit 
-> Bit 
-> (Bit, Bit)

(sum, carry)

Compute the sum and carry bit from adding three bits.

halfAdder Source

Arguments

:: Bit 
-> Bit 
-> (Bit, Bit)

(sum, carry)

Compute the sum and carry bit from adding two bits.