Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module exports everything that Data.PrimitiveArray
exports, but
it will do some bounds-checking on certain operations.
Checked are: (!)
Synopsis
- data family Vector a :: Type
- data family MVector s a :: Type
- data a :. b = !a :. !b
- data a :> b = !a :> !b
- data Z = Z
- class Index i => IndexStream i where
- newtype CellSize = CellSize Word
- newtype SizeError = SizeError String
- class Index i where
- sizeIsValid :: Monad m => Word -> [[Integer]] -> ExceptT SizeError m CellSize
- class FreezeTables m t where
- type Frozen t :: *
- freezeTables :: t -> m (Frozen t)
- data PAErrors = PAEUpperBound
- class Index sh => PrimArrayMap arr sh e e' where
- map :: (e -> e') -> arr sh e -> arr sh e'
- class Index sh => PrimArrayOps arr sh elm where
- upperBound :: arr sh elm -> LimitType sh
- unsafeFreeze :: PrimMonad m => MutArr m (arr sh elm) -> m (arr sh elm)
- unsafeThaw :: PrimMonad m => arr sh elm -> m (MutArr m (arr sh elm))
- unsafeIndex :: arr sh elm -> sh -> elm
- transformShape :: Index sh' => (LimitType sh -> LimitType sh') -> arr sh elm -> arr sh' elm
- class Index sh => MPrimArrayOps arr sh elm where
- upperBoundM :: MutArr m (arr sh elm) -> LimitType sh
- fromListM :: PrimMonad m => LimitType sh -> [elm] -> m (MutArr m (arr sh elm))
- newM :: PrimMonad m => LimitType sh -> m (MutArr m (arr sh elm))
- newWithM :: PrimMonad m => LimitType sh -> elm -> m (MutArr m (arr sh elm))
- readM :: PrimMonad m => MutArr m (arr sh elm) -> sh -> m elm
- writeM :: PrimMonad m => MutArr m (arr sh elm) -> sh -> elm -> m ()
- data family MutArr (m :: * -> *) (arr :: *) :: *
- inBoundsM :: (Monad m, MPrimArrayOps arr sh elm) => MutArr m (arr sh elm) -> sh -> Bool
- fromAssocsM :: (PrimMonad m, MPrimArrayOps arr sh elm) => LimitType sh -> elm -> [(sh, elm)] -> m (MutArr m (arr sh elm))
- newWithPA :: (PrimMonad m, MPrimArrayOps arr sh elm, PrimArrayOps arr sh elm) => LimitType sh -> elm -> m (arr sh elm)
- safeNewWithPA :: forall m arr sh elm. (PrimMonad m, MonadError PAErrors m, MPrimArrayOps arr sh elm, PrimArrayOps arr sh elm) => LimitType sh -> elm -> m (arr sh elm)
- assocs :: forall arr sh elm. (IndexStream sh, PrimArrayOps arr sh elm) => arr sh elm -> [(sh, elm)]
- fromList :: (PrimArrayOps arr sh elm, MPrimArrayOps arr sh elm) => LimitType sh -> [elm] -> arr sh elm
- fromAssocs :: (PrimArrayOps arr sh elm, MPrimArrayOps arr sh elm) => LimitType sh -> elm -> [(sh, elm)] -> arr sh elm
- toList :: forall arr sh elm. (IndexStream sh, PrimArrayOps arr sh elm) => arr sh elm -> [elm]
- data Boxed sh e = Boxed !(LimitType sh) !(Vector e)
- data Unboxed sh e = Unboxed !(LimitType sh) !(Vector e)
- data C
- data O
- data I
- newtype Boundary boundaryType ioc = Boundary {
- getBoundary :: Int
- class ApplyMask s where
- data Fixed t = Fixed {
- getFixedMask :: Mask t
- getFixed :: !t
- type family Mask s :: *
- class SetPredSucc s where
- data Any
- data Last
- data First
- streamUpBndMk :: Monad m => b -> p -> a -> m (a, b)
- streamUpBndStep :: Monad m => p -> Int -> (a, Int) -> m (Step (a, Int) (a :. Boundary boundaryType ioc))
- streamDownBndMk :: Monad m => p -> b -> a -> m (a, b)
- streamDownBndStep :: Monad m => Int -> p -> (a, Int) -> m (Step (a, Int) (a :. Boundary boundaryType ioc))
- arbitraryBitSetMax :: Int
- newtype BitSet t = BitSet {}
- bitSet :: forall t t. Iso (BitSet t) (BitSet t) Int Int
- data BitSet1 i ioc = BitSet1 {}
- bitset :: forall i ioc. Lens' (BitSet1 i ioc) (BitSet ioc)
- boundary :: forall i ioc i. Lens (BitSet1 i ioc) (BitSet1 i ioc) (Boundary i ioc) (Boundary i ioc)
- newtype PInt (ioc :: k) (p :: k) = PInt {}
- pIntI :: Int -> PInt I p
- pIntO :: Int -> PInt O p
- pIntC :: Int -> PInt C p
- newtype PointR t = PointR {
- fromPointR :: Int
- newtype PointL t = PointL {
- fromPointL :: Int
- pointLI :: Int -> PointL I
- pointLO :: Int -> PointL O
- pointLC :: Int -> PointL C
- data SP z = SP !z !Int#
- newtype Subword t = Subword {
- fromSubword :: Int :. Int
- fromSubwordFst :: Subword t -> Int
- fromSubwordSnd :: Subword t -> Int
- subword :: Int -> Int -> Subword t
- subwordI :: Int -> Int -> Subword I
- subwordO :: Int -> Int -> Subword O
- subwordC :: Int -> Int -> Subword C
- data Unit t = Unit
- (!) :: (Index sh, Unbox p, Show sh, Show (LimitType sh)) => Unboxed sh p -> sh -> p
Documentation
data family Vector a :: Type #
Instances
data family MVector s a :: Type #
Instances
Strict pairs -- as in repa
.
!a :. !b infixl 3 |
Instances
A different version of strict pairs. Makes for simpler type inference in
multi-tape grammars. We use :>
when we have special needs, like
non-recursive instances on inductives tuples, as used for set indices.
This one is infixr
so that in a :> b
we can have the main type in
a
and the specializing types in b
and then dispatch on a :> ts
with ts
maybe a chain of :>
.
!a :> !b infixr 3 |
Instances
(Unbox a, Unbox b) => Vector Vector (a :> b) Source # | |
Defined in Data.PrimitiveArray.Index.Class basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (a :> b) -> m (Vector (a :> b)) # basicUnsafeThaw :: PrimMonad m => Vector (a :> b) -> m (Mutable Vector (PrimState m) (a :> b)) # basicLength :: Vector (a :> b) -> Int # basicUnsafeSlice :: Int -> Int -> Vector (a :> b) -> Vector (a :> b) # basicUnsafeIndexM :: Monad m => Vector (a :> b) -> Int -> m (a :> b) # basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (a :> b) -> Vector (a :> b) -> m () # | |
(Unbox a, Unbox b) => MVector MVector (a :> b) Source # | |
Defined in Data.PrimitiveArray.Index.Class basicLength :: MVector s (a :> b) -> Int # basicUnsafeSlice :: Int -> Int -> MVector s (a :> b) -> MVector s (a :> b) # basicOverlaps :: MVector s (a :> b) -> MVector s (a :> b) -> Bool # basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (a :> b)) # basicInitialize :: PrimMonad m => MVector (PrimState m) (a :> b) -> m () # basicUnsafeReplicate :: PrimMonad m => Int -> (a :> b) -> m (MVector (PrimState m) (a :> b)) # basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (a :> b) -> Int -> m (a :> b) # basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (a :> b) -> Int -> (a :> b) -> m () # basicClear :: PrimMonad m => MVector (PrimState m) (a :> b) -> m () # basicSet :: PrimMonad m => MVector (PrimState m) (a :> b) -> (a :> b) -> m () # basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (a :> b) -> MVector (PrimState m) (a :> b) -> m () # basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (a :> b) -> MVector (PrimState m) (a :> b) -> m () # basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (a :> b) -> Int -> m (MVector (PrimState m) (a :> b)) # | |
(Eq a, Eq b) => Eq (a :> b) Source # | |
(Data a, Data b) => Data (a :> b) Source # | |
Defined in Data.PrimitiveArray.Index.Class gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> (a :> b) -> c (a :> b) # gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (a :> b) # toConstr :: (a :> b) -> Constr # dataTypeOf :: (a :> b) -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (a :> b)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (a :> b)) # gmapT :: (forall b0. Data b0 => b0 -> b0) -> (a :> b) -> a :> b # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> (a :> b) -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> (a :> b) -> r # gmapQ :: (forall d. Data d => d -> u) -> (a :> b) -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> (a :> b) -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> (a :> b) -> m (a :> b) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> (a :> b) -> m (a :> b) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> (a :> b) -> m (a :> b) # | |
(Ord a, Ord b) => Ord (a :> b) Source # | |
Defined in Data.PrimitiveArray.Index.Class | |
(Read a, Read b) => Read (a :> b) Source # | |
(Show a, Show b) => Show (a :> b) Source # | |
Generic (a :> b) Source # | |
(Hashable a, Hashable b) => Hashable (a :> b) Source # | |
Defined in Data.PrimitiveArray.Index.Class | |
(ToJSON a, ToJSON b) => ToJSON (a :> b) Source # | |
Defined in Data.PrimitiveArray.Index.Class | |
(FromJSON a, FromJSON b) => FromJSON (a :> b) Source # | |
(Binary a, Binary b) => Binary (a :> b) Source # | |
(Serialize a, Serialize b) => Serialize (a :> b) Source # | |
(NFData a, NFData b) => NFData (a :> b) Source # | |
Defined in Data.PrimitiveArray.Index.Class | |
(Unbox a, Unbox b) => Unbox (a :> b) Source # | |
Defined in Data.PrimitiveArray.Index.Class | |
data MVector s (a :> b) Source # | |
Defined in Data.PrimitiveArray.Index.Class | |
type Rep (a :> b) Source # | |
Defined in Data.PrimitiveArray.Index.Class type Rep (a :> b) = D1 (MetaData ":>" "Data.PrimitiveArray.Index.Class" "PrimitiveArray-0.9.0.0-7o4e78MXLzPCxIvR95QAvs" False) (C1 (MetaCons ":>" (InfixI RightAssociative 3) False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 a) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 b))) | |
data Vector (a :> b) Source # | |
Defined in Data.PrimitiveArray.Index.Class |
Base data constructor for multi-dimensional indices.
Instances
class Index i => IndexStream i where Source #
Generate a stream of indices in correct order for dynamic programming.
Since the stream generators require concatMap
/ flatten
we have to
write more specialized code for (z:.IX)
stuff.
streamUp :: Monad m => LimitType i -> LimitType i -> Stream m i Source #
Generate an index stream using LimitType
s. This prevents having to
figure out how the actual limits for complicated index types (like Set
)
would look like, since for Set
, for example, the LimitType Set == Int
provides just the number of bits.
This generates an index stream suitable for forward
structure filling.
The first index is the smallest (or the first indices considered are all
equally small in partially ordered sets). Larger indices follow up until
the largest one.
streamDown :: Monad m => LimitType i -> LimitType i -> Stream m i Source #
If streamUp
generates indices from smallest to largest, then
streamDown
generates indices from largest to smallest. Outside grammars
make implicit use of this. Asking for an axiom in backtracking requests
the first element from this stream.
Instances
The total number of cells that are allocated.
Instances
Bounded CellSize Source # | |
Enum CellSize Source # | |
Defined in Data.PrimitiveArray.Index.Class | |
Eq CellSize Source # | |
Integral CellSize Source # | |
Defined in Data.PrimitiveArray.Index.Class | |
Num CellSize Source # | |
Ord CellSize Source # | |
Defined in Data.PrimitiveArray.Index.Class | |
Real CellSize Source # | |
Defined in Data.PrimitiveArray.Index.Class toRational :: CellSize -> Rational # | |
Show CellSize Source # | |
In case totalSize
or variants thereof produce a size that is too big to
handle.
Index structures for complex, heterogeneous indexing. Mostly designed for indexing in DP grammars, where the indices work for linear and context-free grammars on one or more tapes, for strings, sets, later on tree structures.
linearIndex :: LimitType i -> i -> Int Source #
Given a maximal size, and a current index, calculate the linear index.
size :: LimitType i -> Int Source #
Given the LimitType
, return the number of cells required for storage.
inBounds :: LimitType i -> i -> Bool Source #
Check if an index is within the bounds.
A lower bound of zero
zeroBound' :: LimitType i Source #
A lower bound of zero
but for a LimitType i
.
totalSize :: LimitType i -> [Integer] Source #
The list of cell sizes for each dimension. its product yields the total size.
Instances
Index Int Source # | |
Defined in Data.PrimitiveArray.Index.Int | |
Index Z Source # | |
Defined in Data.PrimitiveArray.Index.Class | |
(Index zs, Index z) => Index (zs :. z) Source # | |
Defined in Data.PrimitiveArray.Index.Class | |
Index (BitSet t) Source # | |
Defined in Data.PrimitiveArray.Index.BitSet0 | |
Index (PointL t) Source # | |
Defined in Data.PrimitiveArray.Index.Point | |
Index (Subword t) Source # | |
Index (Unit t) Source # | |
Defined in Data.PrimitiveArray.Index.Unit | |
Index (PInt t p) Source # | |
Defined in Data.PrimitiveArray.Index.PhantomInt | |
Index (Boundary i t) Source # | |
Defined in Data.PrimitiveArray.Index.BitSetClasses | |
Index (BitSet1 bnd ioc) Source # | NOTE We linearize a bitset as follows: we need | TODO The size calculations are off by a factor of two, exactly. Each
bitset (say) |
Defined in Data.PrimitiveArray.Index.BitSet1 linearIndex :: LimitType (BitSet1 bnd ioc) -> BitSet1 bnd ioc -> Int Source # size :: LimitType (BitSet1 bnd ioc) -> Int Source # inBounds :: LimitType (BitSet1 bnd ioc) -> BitSet1 bnd ioc -> Bool Source # zeroBound :: BitSet1 bnd ioc Source # zeroBound' :: LimitType (BitSet1 bnd ioc) Source # totalSize :: LimitType (BitSet1 bnd ioc) -> [Integer] Source # |
sizeIsValid :: Monad m => Word -> [[Integer]] -> ExceptT SizeError m CellSize Source #
Given the maximal number of cells (Word
, because this is the pointer
limit for the machine), and the list of sizes, will check if this is still
legal. Consider dividing the Word
by the actual memory requirements for
each cell, to get better exception handling for too large arrays.
One list should be given for each array.
class FreezeTables m t where Source #
freezeTables
freezes a stack of tables.
freezeTables :: t -> m (Frozen t) Source #
Instances
Applicative m => FreezeTables m Z Source # | |
(Functor m, Applicative m, Monad m, PrimMonad m, FreezeTables m ts, PrimArrayOps arr sh elm) => FreezeTables m (ts :. MutArr m (arr sh elm)) Source # | |
class Index sh => PrimArrayMap arr sh e e' where Source #
map :: (e -> e') -> arr sh e -> arr sh e' Source #
Map a function over each element, keeping the shape intact.
class Index sh => PrimArrayOps arr sh elm where Source #
The core set of functions on immutable arrays.
upperBound :: arr sh elm -> LimitType sh Source #
Returns the bounds of an immutable array, again inclusive bounds: [lb..ub]
.
unsafeFreeze :: PrimMonad m => MutArr m (arr sh elm) -> m (arr sh elm) Source #
Freezes a mutable array an returns its immutable version. This operation is O(1) and both arrays share the same memory. Do not use the mutable array afterwards.
unsafeThaw :: PrimMonad m => arr sh elm -> m (MutArr m (arr sh elm)) Source #
Thaw an immutable array into a mutable one. Both versions share memory.
unsafeIndex :: arr sh elm -> sh -> elm Source #
Extract a single element from the array. Generally unsafe as not bounds-checking is performed.
transformShape :: Index sh' => (LimitType sh -> LimitType sh') -> arr sh elm -> arr sh' elm Source #
Savely transform the shape space of a table.
Instances
Index sh => PrimArrayOps Boxed sh elm Source # | |
Defined in Data.PrimitiveArray.Dense upperBound :: Boxed sh elm -> LimitType sh Source # unsafeFreeze :: PrimMonad m => MutArr m (Boxed sh elm) -> m (Boxed sh elm) Source # unsafeThaw :: PrimMonad m => Boxed sh elm -> m (MutArr m (Boxed sh elm)) Source # unsafeIndex :: Boxed sh elm -> sh -> elm Source # transformShape :: Index sh' => (LimitType sh -> LimitType sh') -> Boxed sh elm -> Boxed sh' elm Source # | |
(Index sh, Unbox elm) => PrimArrayOps Unboxed sh elm Source # | |
Defined in Data.PrimitiveArray.Dense upperBound :: Unboxed sh elm -> LimitType sh Source # unsafeFreeze :: PrimMonad m => MutArr m (Unboxed sh elm) -> m (Unboxed sh elm) Source # unsafeThaw :: PrimMonad m => Unboxed sh elm -> m (MutArr m (Unboxed sh elm)) Source # unsafeIndex :: Unboxed sh elm -> sh -> elm Source # transformShape :: Index sh' => (LimitType sh -> LimitType sh') -> Unboxed sh elm -> Unboxed sh' elm Source # |
class Index sh => MPrimArrayOps arr sh elm where Source #
The core set of operations for monadic arrays.
upperBoundM :: MutArr m (arr sh elm) -> LimitType sh Source #
Return the bounds of the array. All bounds are inclusive, as in
[lb..ub]
fromListM :: PrimMonad m => LimitType sh -> [elm] -> m (MutArr m (arr sh elm)) Source #
Given lower and upper bounds and a list of all elements, produce a mutable array.
newM :: PrimMonad m => LimitType sh -> m (MutArr m (arr sh elm)) Source #
Creates a new array with the given bounds with each element within the array being in an undefined state.
newWithM :: PrimMonad m => LimitType sh -> elm -> m (MutArr m (arr sh elm)) Source #
Creates a new array with all elements being equal to elm
.
readM :: PrimMonad m => MutArr m (arr sh elm) -> sh -> m elm Source #
Reads a single element in the array.
writeM :: PrimMonad m => MutArr m (arr sh elm) -> sh -> elm -> m () Source #
Writes a single element in the array.
Instances
data family MutArr (m :: * -> *) (arr :: *) :: * Source #
Mutable version of an array.
Instances
inBoundsM :: (Monad m, MPrimArrayOps arr sh elm) => MutArr m (arr sh elm) -> sh -> Bool Source #
Returns true if the index is valid for the array.
fromAssocsM :: (PrimMonad m, MPrimArrayOps arr sh elm) => LimitType sh -> elm -> [(sh, elm)] -> m (MutArr m (arr sh elm)) Source #
Construct a mutable primitive array from a lower and an upper bound, a default element, and a list of associations.
newWithPA :: (PrimMonad m, MPrimArrayOps arr sh elm, PrimArrayOps arr sh elm) => LimitType sh -> elm -> m (arr sh elm) Source #
Initialize an immutable array but stay within the primitive monad m
.
safeNewWithPA :: forall m arr sh elm. (PrimMonad m, MonadError PAErrors m, MPrimArrayOps arr sh elm, PrimArrayOps arr sh elm) => LimitType sh -> elm -> m (arr sh elm) Source #
Safely prepare a primitive array.
TODO Check if having a MonadError
instance degrades performance. (We
should see this once the test with NeedlemanWunsch is under way).
assocs :: forall arr sh elm. (IndexStream sh, PrimArrayOps arr sh elm) => arr sh elm -> [(sh, elm)] Source #
Return all associations from an array.
fromList :: (PrimArrayOps arr sh elm, MPrimArrayOps arr sh elm) => LimitType sh -> [elm] -> arr sh elm Source #
Creates an immutable array from lower and upper bounds and a complete list of elements.
fromAssocs :: (PrimArrayOps arr sh elm, MPrimArrayOps arr sh elm) => LimitType sh -> elm -> [(sh, elm)] -> arr sh elm Source #
Creates an immutable array from lower and upper bounds, a default element, and a list of associations.
toList :: forall arr sh elm. (IndexStream sh, PrimArrayOps arr sh elm) => arr sh elm -> [elm] Source #
Returns all elements of an immutable array as a list.
Instances
Instances
Phantom type for Complement
indices.
Instances
IndexStream z => IndexStream (z :. BitSet C) Source # | |
IndexStream z => IndexStream (z :. PInt C p) Source # | |
IndexStream z => IndexStream (z :. PointL C) Source # | |
IndexStream z => IndexStream (z :. Subword C) Source # |
|
Phantom type for Outside
indices.
Instances
IndexStream z => IndexStream (z :. BitSet O) Source # | |
IndexStream z => IndexStream (z :. BitSet1 i O) Source # | |
IndexStream z => IndexStream (z :. PInt O p) Source # | |
IndexStream z => IndexStream (z :. PointL O) Source # | |
IndexStream z => IndexStream (z :. Subword O) Source # |
Note: |
Phantom type for Inside
indices.
Instances
IndexStream z => IndexStream (z :. Boundary k2 I) Source # | |
Defined in Data.PrimitiveArray.Index.BitSetClasses | |
IndexStream z => IndexStream (z :. BitSet I) Source # | |
IndexStream z => IndexStream (z :. BitSet1 i I) Source # | |
IndexStream z => IndexStream (z :. PInt I p) Source # | |
IndexStream z => IndexStream (z :. PointL I) Source # | |
IndexStream z => IndexStream (z :. Subword I) Source # |
|
IndexStream (Z :. Boundary k2 I) => IndexStream (Boundary k2 I) Source # | |
newtype Boundary boundaryType ioc 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.
Instances
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.
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
Fixed | |
|
type family Mask s :: * Source #
Masks are used quite often for different types of bitsets. We liberate them as a type family.
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
.
setSucc :: Int -> Int -> 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 :: Int -> Int -> 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.
Instances
SetPredSucc (BitSet t) Source # | |
SetPredSucc (BitSet1 t ioc) Source # | |
Declare the interface to match anything.
TODO needed? want to use later in ADPfusion
streamUpBndMk :: Monad m => b -> p -> a -> m (a, b) Source #
streamUpBndStep :: Monad m => p -> Int -> (a, Int) -> m (Step (a, Int) (a :. Boundary boundaryType ioc)) Source #
streamDownBndMk :: Monad m => p -> b -> a -> m (a, b) Source #
streamDownBndStep :: Monad m => Int -> p -> (a, Int) -> m (Step (a, Int) (a :. Boundary boundaryType ioc)) Source #
arbitraryBitSetMax :: Int Source #
for Arbitrary
Newtype for a bitset.
Int
integrates better with the rest of the framework. But we should
consider moving to Word
-based indexing, if possible.
Instances
The bitset with one interface or boundary.
Instances
Vector Vector (BitSet1 i ioc) Source # | |
Defined in Data.PrimitiveArray.Index.BitSet1 basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (BitSet1 i ioc) -> m (Vector (BitSet1 i ioc)) # basicUnsafeThaw :: PrimMonad m => Vector (BitSet1 i ioc) -> m (Mutable Vector (PrimState m) (BitSet1 i ioc)) # basicLength :: Vector (BitSet1 i ioc) -> Int # basicUnsafeSlice :: Int -> Int -> Vector (BitSet1 i ioc) -> Vector (BitSet1 i ioc) # basicUnsafeIndexM :: Monad m => Vector (BitSet1 i ioc) -> Int -> m (BitSet1 i ioc) # basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (BitSet1 i ioc) -> Vector (BitSet1 i ioc) -> m () # elemseq :: Vector (BitSet1 i ioc) -> BitSet1 i ioc -> b -> b # | |
MVector MVector (BitSet1 i ioc) Source # | |
Defined in Data.PrimitiveArray.Index.BitSet1 basicLength :: MVector s (BitSet1 i ioc) -> Int # basicUnsafeSlice :: Int -> Int -> MVector s (BitSet1 i ioc) -> MVector s (BitSet1 i ioc) # basicOverlaps :: MVector s (BitSet1 i ioc) -> MVector s (BitSet1 i ioc) -> Bool # basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (BitSet1 i ioc)) # basicInitialize :: PrimMonad m => MVector (PrimState m) (BitSet1 i ioc) -> m () # basicUnsafeReplicate :: PrimMonad m => Int -> BitSet1 i ioc -> m (MVector (PrimState m) (BitSet1 i ioc)) # basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (BitSet1 i ioc) -> Int -> m (BitSet1 i ioc) # basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (BitSet1 i ioc) -> Int -> BitSet1 i ioc -> m () # basicClear :: PrimMonad m => MVector (PrimState m) (BitSet1 i ioc) -> m () # basicSet :: PrimMonad m => MVector (PrimState m) (BitSet1 i ioc) -> BitSet1 i ioc -> m () # basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (BitSet1 i ioc) -> MVector (PrimState m) (BitSet1 i ioc) -> m () # basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (BitSet1 i ioc) -> MVector (PrimState m) (BitSet1 i ioc) -> m () # basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (BitSet1 i ioc) -> Int -> m (MVector (PrimState m) (BitSet1 i ioc)) # | |
Show (LimitType (BitSet1 bnd ioc)) Source # | |
IndexStream z => IndexStream (z :. BitSet1 i O) Source # | |
IndexStream z => IndexStream (z :. BitSet1 i I) Source # | |
Eq (BitSet1 i ioc) Source # | |
Ord (BitSet1 i ioc) Source # | |
Defined in Data.PrimitiveArray.Index.BitSet1 compare :: BitSet1 i ioc -> BitSet1 i ioc -> Ordering # (<) :: BitSet1 i ioc -> BitSet1 i ioc -> Bool # (<=) :: BitSet1 i ioc -> BitSet1 i ioc -> Bool # (>) :: BitSet1 i ioc -> BitSet1 i ioc -> Bool # (>=) :: BitSet1 i ioc -> BitSet1 i ioc -> Bool # | |
Show (BitSet1 i ioc) Source # | |
Generic (BitSet1 i ioc) Source # | |
Arbitrary (BitSet1 t ioc) Source # | |
Unbox (BitSet1 i ioc) Source # | |
Defined in Data.PrimitiveArray.Index.BitSet1 | |
IndexStream (Z :. BitSet1 i t) => IndexStream (BitSet1 i t) Source # | |
Index (BitSet1 bnd ioc) Source # | NOTE We linearize a bitset as follows: we need | TODO The size calculations are off by a factor of two, exactly. Each
bitset (say) |
Defined in Data.PrimitiveArray.Index.BitSet1 linearIndex :: LimitType (BitSet1 bnd ioc) -> BitSet1 bnd ioc -> Int Source # size :: LimitType (BitSet1 bnd ioc) -> Int Source # inBounds :: LimitType (BitSet1 bnd ioc) -> BitSet1 bnd ioc -> Bool Source # zeroBound :: BitSet1 bnd ioc Source # zeroBound' :: LimitType (BitSet1 bnd ioc) Source # totalSize :: LimitType (BitSet1 bnd ioc) -> [Integer] Source # | |
SetPredSucc (BitSet1 t ioc) Source # | |
data MVector s (BitSet1 i ioc) Source # | |
Defined in Data.PrimitiveArray.Index.BitSet1 | |
type Rep (BitSet1 i ioc) Source # | |
Defined in Data.PrimitiveArray.Index.BitSet1 type Rep (BitSet1 i ioc) = D1 (MetaData "BitSet1" "Data.PrimitiveArray.Index.BitSet1" "PrimitiveArray-0.9.0.0-7o4e78MXLzPCxIvR95QAvs" False) (C1 (MetaCons "BitSet1" PrefixI True) (S1 (MetaSel (Just "_bitset") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (BitSet ioc)) :*: S1 (MetaSel (Just "_boundary") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Boundary i ioc)))) | |
data Vector (BitSet1 i ioc) Source # | |
data LimitType (BitSet1 bnd ioc) Source # | |
Defined in Data.PrimitiveArray.Index.BitSet1 |
boundary :: forall i ioc i. Lens (BitSet1 i ioc) (BitSet1 i ioc) (Boundary i ioc) (Boundary i ioc) Source #
newtype PInt (ioc :: k) (p :: k) Source #
A PInt
behaves exactly like an Int
, but has an attached phantom
type p
. In particular, the Index
and IndexStream
instances are the
same as for raw Int
s.
Instances
A point in a right-linear grammars.
PointR | |
|
A point in a left-linear grammar. The syntactic symbol is in left-most position.
PointL | |
|
Instances
A subword wraps a pair of Int
indices i,j
with i<=j
.
Subwords always yield the upper-triangular part of a rect-angular array.
This gives the quite curious effect that (0,N)
points to the
`largest'
index, while (0,0) ... (1,1) ... (k,k) ... (N,N)
point to
the smallest. We do, however, use (0,0) as the smallest as (0,k) gives
successively smaller upper triangular parts.
Subword | |
|
Instances
fromSubwordFst :: Subword t -> Int Source #
fromSubwordSnd :: Subword t -> Int Source #