| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.PrimitiveArray.Index.Subword
Description
Index structure for context-free grammars on strings. A Subword captures
a pair (i,j) with i<=j.
- newtype Subword t = Subword {
- fromSubword :: Int :. Int
- subword :: Int -> Int -> Subword t
- subwordI :: Int -> Int -> Subword I
- subwordO :: Int -> Int -> Subword O
- subwordC :: Int -> Int -> Subword C
- triangularNumber :: Int -> Int
- upperTri :: Subword t -> Int
- subwordIndex :: Subword s -> Subword t -> Int
- subwordFromIndex :: Subword s -> Int -> Subword t
- streamUpMk :: Monad m => t1 -> t -> m (t, t1, t1)
- streamUpStep :: Monad m => Int -> Int -> (t1, Int, Int) -> m (Step (t1, Int, Int) ((:.) t1 (Subword t)))
- streamDownMk :: Monad m => t1 -> t2 -> t -> m (t, t1, t2)
- streamDownStep :: Monad m => Int -> (t1, Int, Int) -> m (Step (t1, Int, Int) ((:.) t1 (Subword t)))
Documentation
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.
Constructors
| Subword | |
Fields
| |
Instances
| Vector Vector (Subword t) Source | |
| MVector MVector (Subword t) Source | |
| Eq (Subword t) Source | |
| Ord (Subword t) Source | |
| Read (Subword t) Source | |
| Show (Subword t) Source | |
| Generic (Subword t) Source | |
| Arbitrary (Subword t) Source | |
| ToJSON (Subword t) Source | |
| FromJSON (Subword t) Source | |
| Binary (Subword t) Source | |
| Serialize (Subword t) Source | |
| NFData (Subword t) Source | |
| Hashable (Subword t) Source | |
| Unbox (Subword t) Source | |
| IndexStream ((:.) Z (Subword t)) => IndexStream (Subword t) Source | |
| Index (Subword t) Source | |
| IndexStream z => IndexStream ((:.) z (Subword C)) Source | |
| IndexStream z => IndexStream ((:.) z (Subword O)) Source |
Note: |
| IndexStream z => IndexStream ((:.) z (Subword I)) Source |
|
| data MVector s0 (Subword t0) = MV_Subword (MVector s (Int, Int)) Source | |
| type Rep (Subword t) Source | |
| data Vector (Subword t0) = V_Subword (Vector (Int, Int)) Source |
triangularNumber :: Int -> Int Source
triangular numbers
A000217
upperTri :: Subword t -> Int Source
Size of an upper triangle starting at i and ending at j. "(0,N)" what
be the normal thing to use.
subwordIndex :: Subword s -> Subword t -> Int Source
Subword indexing. Given the longest subword and the current subword, calculate a linear index "[0,..]". "(l,n)" in this case means "l"ower bound, length "n". And "(i,j)" is the normal index.
TODO probably doesn't work right with non-zero base ?!
subwordFromIndex :: Subword s -> Int -> Subword t Source
streamUpMk :: Monad m => t1 -> t -> m (t, t1, t1) Source
generic mk for streamUp / streamDown
streamUpStep :: Monad m => Int -> Int -> (t1, Int, Int) -> m (Step (t1, Int, Int) ((:.) t1 (Subword t))) Source
streamDownMk :: Monad m => t1 -> t2 -> t -> m (t, t1, t2) Source