Safe Haskell | None |
---|---|
Language | Haskell2010 |
Documentation
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
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.
In case totalSize
or variants thereof produce a size that is too big to
handle.
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 # | |
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.