Copyright | (c) Artem Chirkin |
---|---|
License | BSD3 |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data Idx (n :: k) where
- pattern Idx :: forall (k :: Type) (n :: k). BoundedDim n => Word -> Idx n
- type Idxs (xs :: [k]) = TypedList Idx xs
- idxFromWord :: forall (k :: Type) (d :: k). BoundedDim d => Word -> Maybe (Idx d)
- unsafeIdxFromWord :: forall (k :: Type) (d :: k). BoundedDim d => Word -> Idx d
- idxToWord :: forall (k :: Type) (d :: k). Idx d -> Word
- listIdxs :: forall (k :: Type) (xs :: [k]). Idxs xs -> [Word]
- idxsFromWords :: forall (k :: Type) (xs :: [k]). BoundedDims xs => [Word] -> Maybe (Idxs xs)
Data types
data Idx (n :: k) where Source #
This type is used to index a single dimension;
the range of indices is from 0
to n-1
.
pattern Idx :: forall (k :: Type) (n :: k). BoundedDim n => Word -> Idx n | If the word is outside of the bounds, fails with an error
(unless |
Instances
BoundedDims ds => Bounded (Idxs ds) Source # | |
BoundedDim n => Bounded (Idx n) Source # | |
Dimensions ds => Enum (Idxs ds) Source # | |
BoundedDim n => Enum (Idx n) Source # | |
Defined in Numeric.Dimensions.Idx | |
Eq (Idxs xs) Source # | |
Eq (Idx n) Source # | |
BoundedDim n => Integral (Idx n) Source # | |
(Typeable n, Typeable k) => Data (Idx n) Source # | |
Defined in Numeric.Dimensions.Idx gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Idx n -> c (Idx n) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Idx n) # dataTypeOf :: Idx n -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Idx n)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Idx n)) # gmapT :: (forall b. Data b => b -> b) -> Idx n -> Idx n # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Idx n -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Idx n -> r # gmapQ :: (forall d. Data d => d -> u) -> Idx n -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Idx n -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Idx n -> m (Idx n) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Idx n -> m (Idx n) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Idx n -> m (Idx n) # | |
BoundedDim n => Num (Idxs (n ': ([] :: [k]))) Source # | With this instance we can slightly reduce indexing expressions, e.g. x ! (1 :* 2 :* 4) == x ! (1 :* 2 :* 4 :* U) |
Defined in Numeric.Dimensions.Idx (+) :: Idxs (n ': []) -> Idxs (n ': []) -> Idxs (n ': []) # (-) :: Idxs (n ': []) -> Idxs (n ': []) -> Idxs (n ': []) # (*) :: Idxs (n ': []) -> Idxs (n ': []) -> Idxs (n ': []) # negate :: Idxs (n ': []) -> Idxs (n ': []) # abs :: Idxs (n ': []) -> Idxs (n ': []) # signum :: Idxs (n ': []) -> Idxs (n ': []) # fromInteger :: Integer -> Idxs (n ': []) # | |
BoundedDim n => Num (Idx n) Source # | |
Ord (Idxs xs) Source # | Compare indices by their importance in lexicorgaphic order from the first dimension to the last dimension (the first dimension is the most significant one). Literally, compare a b = compare (listIdxs a) (listIdxs b) This is the same sort == sortOn fromEnum |
Ord (Idx n) Source # | |
BoundedDims xs => Read (Idxs xs) Source # | |
BoundedDim x => Read (Idx x) Source # | |
BoundedDim n => Real (Idx n) Source # | |
Defined in Numeric.Dimensions.Idx toRational :: Idx n -> Rational # | |
Show (Idxs xs) Source # | |
Show (Idx x) Source # | |
Generic (Idx n) Source # | |
Storable (Idx n) Source # | |
type Rep (Idx n) Source # | |
Defined in Numeric.Dimensions.Idx |
type Idxs (xs :: [k]) = TypedList Idx xs Source #
Type-level dimensional indexing with arbitrary Word values inside.
Most of the operations on it require Dimensions
constraint,
because the Idxs
itself does not store info about dimension bounds.
idxFromWord :: forall (k :: Type) (d :: k). BoundedDim d => Word -> Maybe (Idx d) Source #
Convert an arbitrary Word to Idx
.
unsafeIdxFromWord :: forall (k :: Type) (d :: k). BoundedDim d => Word -> Idx d Source #
Convert an arbitrary Word to Idx
.
If the word is outside of the bounds, fails with an error
(unless unsafeindices
flag is turned on).
idxsFromWords :: forall (k :: Type) (xs :: [k]). BoundedDims xs => [Word] -> Maybe (Idxs xs) Source #