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
- data family MVector s a
- data a :. b = !a :. !b
- data a :> b = !a :> !b
- data Z = Z
- class SparseBucket sh where
- class Index i => IndexStream i where
- newtype CellSize = CellSize Word
- newtype SizeError = SizeError String
- class Index i where
- data LimitType i :: *
- linearIndex :: LimitType i -> i -> Int
- fromLinearIndex :: LimitType i -> Int -> i
- size :: LimitType i -> Int
- inBounds :: LimitType i -> i -> Bool
- zeroBound :: i
- zeroBound' :: LimitType i
- totalSize :: LimitType i -> [Integer]
- showBound :: LimitType i -> [String]
- showIndex :: i -> [String]
- sizeIsValid :: Monad m => Word -> [[Integer]] -> ExceptT SizeError m CellSize
- data PAErrors = PAEUpperBound
- class PrimArrayMap arr sh e e' where
- mapArray :: (e -> e') -> arr sh e -> arr sh e'
- class Index sh => PrimArrayOps arr sh elm where
- upperBound :: arr sh elm -> LimitType sh
- unsafeIndex :: arr sh elm -> sh -> elm
- safeIndex :: arr sh elm -> sh -> Maybe elm
- transformShape :: Index sh' => (LimitType sh -> LimitType sh') -> arr sh elm -> arr sh' elm
- 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))
- newSM :: (Monad m, PrimMonad m) => LimitType sh -> FillStruc (arr sh elm) -> m (MutArr m (arr sh elm))
- newWithM :: PrimMonad m => LimitType sh -> elm -> m (MutArr m (arr sh elm))
- newWithSM :: (Monad m, PrimMonad m) => LimitType sh -> FillStruc (arr sh elm) -> elm -> m (MutArr m (arr sh elm))
- readM :: PrimMonad m => MutArr m (arr sh elm) -> sh -> m elm
- safeReadM :: (Monad m, PrimMonad m) => MutArr m (arr sh elm) -> sh -> m (Maybe elm)
- writeM :: PrimMonad m => MutArr m (arr sh elm) -> sh -> elm -> m ()
- safeWriteM :: (Monad m, PrimMonad m) => MutArr m (arr sh elm) -> sh -> elm -> m ()
- unsafeFreezeM :: PrimMonad m => MutArr m (arr sh elm) -> m (arr sh elm)
- unsafeThawM :: PrimMonad m => arr sh elm -> m (MutArr m (arr sh elm))
- type family FillStruc arr :: *
- data family MutArr (m :: * -> *) (arr :: *) :: *
- (!?) :: PrimArrayOps arr sh elm => arr sh elm -> sh -> Maybe elm
- inBoundsM :: (Monad m, PrimArrayOps arr sh elm) => MutArr m (arr sh elm) -> sh -> Bool
- fromAssocsM :: (PrimMonad m, PrimArrayOps arr sh elm) => LimitType sh -> elm -> [(sh, elm)] -> m (MutArr m (arr sh elm))
- newWithPA :: (PrimMonad m, PrimArrayOps arr sh elm) => LimitType sh -> elm -> m (arr sh elm)
- newWithSPA :: (PrimMonad m, PrimArrayOps arr sh elm) => LimitType sh -> FillStruc (arr sh elm) -> elm -> m (arr sh elm)
- safeNewWithPA :: forall m arr sh elm. (PrimMonad m, MonadError PAErrors m, 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)]
- assocsS :: forall m arr sh elm. (Monad m, IndexStream sh, PrimArrayOps arr sh elm) => arr sh elm -> Stream m (sh, elm)
- fromList :: PrimArrayOps arr sh elm => LimitType sh -> [elm] -> arr sh elm
- fromAssocs :: PrimArrayOps 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 Dense v sh e = Dense {
- _denseLimit :: !(LimitType sh)
- _denseV :: !(v e)
- type Boxed sh e = Dense Vector sh e
- type Storable sh e = Dense Vector sh e
- type Unboxed sh e = Dense Vector sh e
- denseLimit :: forall k (v :: k -> Type) sh (e :: k) sh. Lens (Dense (v :: k -> Type) sh (e :: k)) (Dense (v :: k -> Type) sh (e :: k)) (LimitType sh) (LimitType sh)
- denseV :: forall k (v :: k -> Type) sh (e :: k) k (v :: k -> Type) (e :: k). Lens (Dense (v :: k -> Type) sh (e :: k)) (Dense (v :: k -> Type) sh (e :: k)) (v e) (v e)
- data C
- data O
- data I
- newtype Boundary boundaryType ioc = Boundary {
- getBoundary :: Int
- pattern UndefBoundary :: Boundary boundaryType ioc
- class ApplyMask s where
- data FixedMask t = FixedMask {}
- type family Mask s :: *
- class SetPredSucc s where
- data Any
- data Last
- data First
- streamUpBndMk :: Monad m => b -> p -> a -> m (a, b)
- streamUpBndStep :: forall k1 k2 m p a (boundaryType :: k1) (ioc :: k2). Monad m => p -> Int -> (a, Int) -> m (Step (a, Int) (a :. Boundary boundaryType ioc))
- streamDownBndMk :: Monad m => p -> b -> a -> m (a, b)
- streamDownBndStep :: forall k1 k2 m p a (boundaryType :: k1) (ioc :: k2). Monad m => Int -> p -> (a, Int) -> m (Step (a, Int) (a :. Boundary boundaryType ioc))
- arbitraryBitSetMax :: Int
- newtype BitSet t = BitSet {}
- bitSet :: forall k (t :: k) k (t :: k). Iso (BitSet (t :: k)) (BitSet (t :: k)) Int Int
- data BitSet1 i ioc = BitSet1 {}
- bitset :: forall k (i :: k) k (ioc :: k). Lens' (BitSet1 (i :: k) (ioc :: k)) (BitSet ioc)
- boundary :: forall k (i :: k) k (ioc :: k) k (i :: k). Lens (BitSet1 (i :: k) (ioc :: k)) (BitSet1 (i :: k) (ioc :: k)) (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 PointL t = PointL {
- fromPointL :: Int
- pointLI :: Int -> PointL I
- pointLO :: Int -> PointL O
- pointLC :: Int -> PointL C
- newtype PointR t = PointR {
- fromPointR :: Int
- data SP z = SP !z !Int#
- arbMaxPointR :: 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
- (!) :: forall (v :: Type -> Type) p sh. (Vector v p, Index sh, Show sh, Show (LimitType sh)) => Dense v sh p -> sh -> p
Documentation
Instances
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 :: forall r r'. (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 # | |
(NFData a, NFData b) => NFData (a :> b) Source # | |
Defined in Data.PrimitiveArray.Index.Class | |
(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 # | |
(Unbox a, Unbox b) => Unbox (a :> b) Source # | |
Defined in Data.PrimitiveArray.Index.Class | |
newtype 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.10.1.0-8LhqXNFuZNc70s43xh6tNJ" '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))) | |
newtype Vector (a :> b) Source # | |
Defined in Data.PrimitiveArray.Index.Class |
Base data constructor for multi-dimensional indices.
Instances
class SparseBucket sh where Source #
manhattan
turns an index sh
into a starting point within sparseIndices
of the Sparse
data structure. This should reduce the time required to search sparseIndices
, because
manhattanStart[manhattan sh]
yields a left bound, while manhattanStart[manhattan sh +1]
will
yield an excluded right bound.
Uses the Manhattan
distance.
TODO This should probably be moved into the Index
module.
manhattan :: LimitType sh -> sh -> Int Source #
The manhattan distance for an index.
manhattanMax :: LimitType sh -> Int Source #
The maximal possible manhattan distance.
Instances
SparseBucket Z Source # | |
(SparseBucket i, SparseBucket is) => SparseBucket (is :. i) Source # | Manhattan distances add up. |
SparseBucket (PointL O) Source # | TODO Is this instance correct? Outside indices shrink? |
SparseBucket (PointL I) Source # | |
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.
fromLinearIndex :: LimitType i -> Int -> i Source #
Given a maximal size and a valid Int
, return the 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.
showBound :: LimitType i -> [String] Source #
Pretty-print all upper bounds
showIndex :: i -> [String] Source #
Pretty-print all indices
Instances
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.
Sum type of errors that can happen when using primitive arrays.
class PrimArrayMap arr sh e e' where Source #
class Index sh => PrimArrayOps arr sh elm where Source #
The core set of operations for pure and monadic arrays.
upperBound :: arr sh elm -> LimitType sh Source #
Returns the bounds of an immutable array, again inclusive bounds: [lb..ub]
.
unsafeIndex :: arr sh elm -> sh -> elm Source #
Extract a single element from the array. Generally unsafe as not bounds-checking is performed.
safeIndex :: arr sh elm -> sh -> Maybe elm Source #
Index into immutable array, but safe in case sh
is not part of the array.
transformShape :: Index sh' => (LimitType sh -> LimitType sh') -> arr sh elm -> arr sh' elm Source #
Savely transform the shape space of a table.
upperBoundM :: MutArr m (arr sh elm) -> LimitType sh Source #
Return the bounds of the array. All bounds are inclusive, as in [lb..ub]
. Technically not
monadic, but rather working on a monadic array.
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.
newSM :: (Monad m, PrimMonad m) => LimitType sh -> FillStruc (arr sh elm) -> m (MutArr m (arr sh elm)) Source #
Variant of newM
that requires a fill structure. Mostly for special / sparse structures
(hence the S
, also to be interpreted as "safe", since these functions won't fail with sparse
structures).
newWithM :: PrimMonad m => LimitType sh -> elm -> m (MutArr m (arr sh elm)) Source #
Creates a new array with all elements being equal to elm
.
newWithSM :: (Monad m, PrimMonad m) => LimitType sh -> FillStruc (arr sh elm) -> elm -> m (MutArr m (arr sh elm)) Source #
Variant of newWithM
readM :: PrimMonad m => MutArr m (arr sh elm) -> sh -> m elm Source #
Reads a single element in the array.
safeReadM :: (Monad m, PrimMonad m) => MutArr m (arr sh elm) -> sh -> m (Maybe elm) Source #
Read from the mutable array, but return Nothing
in case sh
does not exist. This will
allow streaming DP combinators to "jump" over missing elements.
Should be used with Stream.Monadic.mapMaybe
to get efficient code.
writeM :: PrimMonad m => MutArr m (arr sh elm) -> sh -> elm -> m () Source #
Writes a single element in the array.
safeWriteM :: (Monad m, PrimMonad m) => MutArr m (arr sh elm) -> sh -> elm -> m () Source #
Write into the mutable array, but if the index sh
does not exist, silently continue.
unsafeFreezeM :: 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.
unsafeThawM :: PrimMonad m => arr sh elm -> m (MutArr m (arr sh elm)) Source #
Thaw an immutable array into a mutable one. Both versions share memory.
Instances
type family FillStruc arr :: * Source #
Associate a fill structure with each type of array (dense, sparse, ...).
Example: type instance FillStruc (Sparse w v sh e) = (w sh)
associates the type (w sh)
, which
is of the same type as the underlying w
structure holding index information for a sparse array.
data family MutArr (m :: * -> *) (arr :: *) :: * Source #
Mutable version of an array.
Instances
(!?) :: PrimArrayOps arr sh elm => arr sh elm -> sh -> Maybe elm Source #
Return value at an index that might not exist.
inBoundsM :: (Monad m, PrimArrayOps arr sh elm) => MutArr m (arr sh elm) -> sh -> Bool Source #
Returns true if the index is valid for the array.
fromAssocsM :: (PrimMonad m, PrimArrayOps 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, PrimArrayOps arr sh elm) => LimitType sh -> elm -> m (arr sh elm) Source #
Initialize an immutable array but stay within the primitive monad m
.
newWithSPA :: (PrimMonad m, PrimArrayOps arr sh elm) => LimitType sh -> FillStruc (arr sh elm) -> elm -> m (arr sh elm) Source #
Initialize an immutable array with a fill structure.
safeNewWithPA :: forall m arr sh elm. (PrimMonad m, MonadError PAErrors m, 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.
assocsS :: forall m arr sh elm. (Monad m, IndexStream sh, PrimArrayOps arr sh elm) => arr sh elm -> Stream m (sh, elm) Source #
Return all associations from an array.
fromList :: PrimArrayOps 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 => 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.
Dense | |
|
Instances
(Index sh, Vector v e, Vector v e') => PrimArrayMap (Dense v :: Type -> Type -> Type) (sh :: Type) e e' Source # | |
(Show (LimitType sh), Show (Mutable v (PrimState m) e), Mutable v (PrimState m) e ~ mv) => Show (MutArr m (Dense v sh e)) Source # | |
Generic (MutArr m (Dense v sh e)) Source # | |
(NFData (LimitType sh), NFData (Mutable v (PrimState m) e), Mutable v (PrimState m) e ~ mv) => NFData (MutArr m (Dense v sh e)) Source # | |
Defined in Data.PrimitiveArray.Dense | |
(Index sh, Vector v e) => PrimArrayOps (Dense v) sh e Source # | |
Defined in Data.PrimitiveArray.Dense upperBound :: Dense v sh e -> LimitType sh Source # unsafeIndex :: Dense v sh e -> sh -> e Source # safeIndex :: Dense v sh e -> sh -> Maybe e Source # transformShape :: Index sh' => (LimitType sh -> LimitType sh') -> Dense v sh e -> Dense v sh' e Source # upperBoundM :: forall (m :: Type -> Type). MutArr m (Dense v sh e) -> LimitType sh Source # fromListM :: PrimMonad m => LimitType sh -> [e] -> m (MutArr m (Dense v sh e)) Source # newM :: PrimMonad m => LimitType sh -> m (MutArr m (Dense v sh e)) Source # newSM :: (Monad m, PrimMonad m) => LimitType sh -> FillStruc (Dense v sh e) -> m (MutArr m (Dense v sh e)) Source # newWithM :: PrimMonad m => LimitType sh -> e -> m (MutArr m (Dense v sh e)) Source # newWithSM :: (Monad m, PrimMonad m) => LimitType sh -> FillStruc (Dense v sh e) -> e -> m (MutArr m (Dense v sh e)) Source # readM :: PrimMonad m => MutArr m (Dense v sh e) -> sh -> m e Source # safeReadM :: (Monad m, PrimMonad m) => MutArr m (Dense v sh e) -> sh -> m (Maybe e) Source # writeM :: PrimMonad m => MutArr m (Dense v sh e) -> sh -> e -> m () Source # safeWriteM :: (Monad m, PrimMonad m) => MutArr m (Dense v sh e) -> sh -> e -> m () Source # unsafeFreezeM :: PrimMonad m => MutArr m (Dense v sh e) -> m (Dense v sh e) Source # unsafeThawM :: PrimMonad m => Dense v sh e -> m (MutArr m (Dense v sh e)) Source # | |
Functor v => Functor (Dense v sh) Source # | |
(Eq (LimitType sh), Eq (v e)) => Eq (Dense v sh e) Source # | |
(Data (v e), Data (LimitType sh), Data e, Data sh, Typeable sh, Typeable e, Typeable v) => Data (Dense v sh e) Source # | |
Defined in Data.PrimitiveArray.Dense gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Dense v sh e -> c (Dense v sh e) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Dense v sh e) # toConstr :: Dense v sh e -> Constr # dataTypeOf :: Dense v sh e -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Dense v sh e)) # dataCast2 :: Typeable t => (forall d e0. (Data d, Data e0) => c (t d e0)) -> Maybe (c (Dense v sh e)) # gmapT :: (forall b. Data b => b -> b) -> Dense v sh e -> Dense v sh e # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Dense v sh e -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Dense v sh e -> r # gmapQ :: (forall d. Data d => d -> u) -> Dense v sh e -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Dense v sh e -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Dense v sh e -> m (Dense v sh e) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Dense v sh e -> m (Dense v sh e) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Dense v sh e -> m (Dense v sh e) # | |
(Read (LimitType sh), Read (v e)) => Read (Dense v sh e) Source # | |
(Show (LimitType sh), Show (v e)) => Show (Dense v sh e) Source # | |
(Generic (LimitType sh), Generic (v e)) => Generic (Dense v sh e) Source # | |
(NFData (LimitType sh), NFData (v e)) => NFData (Dense v sh e) Source # | |
Defined in Data.PrimitiveArray.Dense | |
(Hashable (LimitType sh), Hashable (v e), Generic (LimitType sh), Generic (v e)) => Hashable (Dense v sh e) Source # | |
Defined in Data.PrimitiveArray.Dense | |
(ToJSON (LimitType sh), ToJSON (v e), Generic (LimitType sh), Generic (v e)) => ToJSON (Dense v sh e) Source # | |
Defined in Data.PrimitiveArray.Dense | |
(FromJSON (LimitType sh), FromJSON (v e), Generic (LimitType sh), Generic (v e)) => FromJSON (Dense v sh e) Source # | |
(Binary (LimitType sh), Binary (v e), Generic (LimitType sh), Generic (v e)) => Binary (Dense v sh e) Source # | |
(Serialize (LimitType sh), Serialize (v e), Generic (LimitType sh), Generic (v e)) => Serialize (Dense v sh e) Source # | |
data MutArr m (Dense v sh e) Source # | |
type Rep (MutArr m (Dense v sh e)) Source # | |
Defined in Data.PrimitiveArray.Dense type Rep (MutArr m (Dense v sh e)) = D1 ('MetaData "MutArr" "Data.PrimitiveArray.Dense" "PrimitiveArray-0.10.1.0-8LhqXNFuZNc70s43xh6tNJ" 'False) (C1 ('MetaCons "MDense" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (LimitType sh)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Mutable v (PrimState m) e)))) | |
type Rep (Dense v sh e) Source # | |
Defined in Data.PrimitiveArray.Dense type Rep (Dense v sh e) = D1 ('MetaData "Dense" "Data.PrimitiveArray.Dense" "PrimitiveArray-0.10.1.0-8LhqXNFuZNc70s43xh6tNJ" 'False) (C1 ('MetaCons "Dense" 'PrefixI 'True) (S1 ('MetaSel ('Just "_denseLimit") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (LimitType sh)) :*: S1 ('MetaSel ('Just "_denseV") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (v e)))) |
denseLimit :: forall k (v :: k -> Type) sh (e :: k) sh. Lens (Dense (v :: k -> Type) sh (e :: k)) (Dense (v :: k -> Type) sh (e :: k)) (LimitType sh) (LimitType sh) Source #
denseV :: forall k (v :: k -> Type) sh (e :: k) k (v :: k -> Type) (e :: k). Lens (Dense (v :: k -> Type) sh (e :: k)) (Dense (v :: k -> Type) sh (e :: k)) (v e) (v e) Source #
Phantom type for Complement
indices.
Instances
IndexStream z => IndexStream (z :. BitSet C) Source # | |
Defined in Data.PrimitiveArray.Index.BitSet0 | |
IndexStream z => IndexStream (z :. PInt C p) Source # | |
Defined in Data.PrimitiveArray.Index.PhantomInt | |
IndexStream z => IndexStream (z :. PointL C) Source # | |
Defined in Data.PrimitiveArray.Index.Point | |
IndexStream z => IndexStream (z :. Subword C) Source # |
|
Defined in Data.PrimitiveArray.Index.Subword |
Phantom type for Outside
indices.
Instances
Phantom type for Inside
indices.
Instances
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
pattern UndefBoundary :: Boundary boundaryType ioc Source #
Whenever we can not set the boundary we should have for a set, we use this
pattern. All legal boundaries are >=0
. We also need to set the undefined
boundary to 0
, since the linearIndex
will use this value to add, which
for empty sets would reduce to 0 - UndefBoundary === 0
.
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.
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
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 (FixedMask (BitSet1 t ioc)) Source # | |
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 :: forall k1 k2 m p a (boundaryType :: k1) (ioc :: k2). 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 :: forall k1 k2 m p a (boundaryType :: k1) (ioc :: k2). 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
boundary :: forall k (i :: k) k (ioc :: k) k (i :: k). Lens (BitSet1 (i :: k) (ioc :: k)) (BitSet1 (i :: k) (ioc :: k)) (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 left-linear grammar. The syntactic symbol is in left-most position.
PointL | |
|
Instances
A point in a right-linear grammars.
PointR | |
|
Instances
arbMaxPointR :: Int Source #
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 #