PrimitiveArray-0.6.1.0: Efficient multidimensional arrays

Safe HaskellNone
LanguageHaskell2010

Data.PrimitiveArray.Index.Set

Contents

Description

Set with and without interfaces. We provide instances for sets, and sets with one or two interfaces. The First and Last annotation is purely cosmetical (apart from introducing type safety).

Synopsis

newtypes, data types, classes.

newtype Interface t Source

Certain sets have an interface, a particular element with special meaning. In this module, certain ``meanings'' are already provided. These include a First element and a Last element. We phantom-type these to reduce programming overhead.

Constructors

Iter 

Fields

getIter :: Int
 

data First Source

Declare the interface to be the start of a path.

data Last Source

Declare the interface to be the end of a path.

data Any Source

Declare the interface to match anything.

TODO needed? want to use later in ADPfusion

type BS1I i = BitSet :> Interface i Source

A bitset with one interface.

type BS2I i j = (BitSet :> Interface i) :> Interface j Source

A bitset with two interfaces.

class SetPredSucc s where Source

Successor and Predecessor for sets. Designed as a class to accomodate sets with interfaces and without interfaces with one function.

The functions are not written recursively, as we currently only have three cases, and we do not want to "reset" while generating successors and predecessors.

Note that sets have a partial order. Within the group of element with the same popCount, we use popPermutation which has the same stepping order for both, setSucc and setPred.

Methods

setSucc :: s -> s -> s -> Maybe s Source

Set successor. The first argument is the lower set limit, the second the upper set limit, the third the current set.

setPred :: s -> s -> s -> Maybe s Source

Set predecessor. The first argument is the lower set limit, the second the upper set limit, the third the current set.

type family Mask s :: * Source

Masks are used quite often for different types of bitsets. We liberate them as a type family.

Instances

data Fixed t Source

Fixed allows us to fix some or all bits of a bitset, thereby providing succ/pred operations which are only partially free.

The mask is lazy, this allows us to have undefined for l and h.

f = getFixedMask .&. getFixed are the fixed bits. n = getFixed .&. complement getFixedMask are the free bits. to = complement getFixed is the to move mask n' = popShiftR to n yields the population after the move p = popPermutation undefined n' yields the new population permutation p' = popShiftL to p yields the population moved back final = p' .|. f

Constructors

Fixed 

Fields

getFixedMask :: Mask t
 
getFixed :: !t
 

Instances

(Unbox t0, Unbox (Mask t0)) => Vector Vector (Fixed t) 
(Unbox t0, Unbox (Mask t0)) => MVector MVector (Fixed t) 
(Eq t, Eq (Mask t)) => Eq (Fixed t) 
(Ord t, Ord (Mask t)) => Ord (Fixed t) 
(Read t, Read (Mask t)) => Read (Fixed t) 
(Show t, Show (Mask t)) => Show (Fixed t) 
(Generic t, Generic (Mask t)) => Generic (Fixed t) 
(Arbitrary t, Arbitrary (Mask t)) => Arbitrary (Fixed t) 
(Generic t, Generic (Mask t), Binary t, Binary (Mask t)) => Binary (Fixed t) 
(Generic t, Generic (Mask t), Serialize t, Serialize (Mask t)) => Serialize (Fixed t) 
NFData (Fixed t) 
(Unbox t0, Unbox (Mask t0)) => Unbox (Fixed t) 
SetPredSucc (Fixed ((:>) ((:>) BitSet (Interface i)) (Interface j))) 
SetPredSucc (Fixed ((:>) BitSet (Interface i))) 
SetPredSucc (Fixed BitSet) 
data MVector s0 (Fixed t0) = MV_Fixed (MVector s (Mask t, t)) 
type Rep (Fixed t) 
data Vector (Fixed t0) = V_Fixed (Vector (Mask t, t)) 

class ApplyMask s where Source

Assuming a bitset on bits [0 .. highbit], we can apply a mask that stretches out those bits over [0 .. higherBit] with highbit <= higherBit. Any active interfaces are correctly set as well.

Methods

applyMask :: Mask s -> s -> s Source

Instances