| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
DiffLoc.Index
Description
Indices and offsets.
Synopsis
- newtype Plain a = Plain a
- data IndexFrom (n :: Nat) a
- indexFromM :: forall n a. (KnownNat n, Num a, Ord a) => a -> Maybe (IndexFrom n a)
- indexFromM0 :: forall a. (Num a, Ord a) => a -> Maybe (IndexFrom 0 a)
- indexFromM1 :: forall a. (Num a, Ord a) => a -> Maybe (IndexFrom 1 a)
- fromIndex :: forall n a. IndexFrom n a -> a
- fromIndex0 :: IndexFrom 0 a -> a
- fromIndex1 :: IndexFrom 1 a -> a
- zeroIndex :: Num a => IndexFrom 1 a -> IndexFrom 0 a
- oneIndex :: Num a => IndexFrom 0 a -> IndexFrom 1 a
- data Offset a
- offsetM :: (Num a, Ord a) => a -> Maybe (Offset a)
- fromOffset :: Offset a -> a
One-dimensional indices
Unbounded indices
One-dimensional indices.
Constructors
| Plain a |
Instances
| Show a => Show (Plain a) Source # | |
| (Num a, Ord a) => Amor (Plain a) Source # | |
| Eq a => Eq (Plain a) Source # | |
| Ord a => Ord (Plain a) Source # | |
| Num a => Num (Plain :$: a) Source # | |
Defined in DiffLoc.Starter Methods (+) :: (Plain :$: a) -> (Plain :$: a) -> Plain :$: a # (-) :: (Plain :$: a) -> (Plain :$: a) -> Plain :$: a # (*) :: (Plain :$: a) -> (Plain :$: a) -> Plain :$: a # negate :: (Plain :$: a) -> Plain :$: a # abs :: (Plain :$: a) -> Plain :$: a # signum :: (Plain :$: a) -> Plain :$: a # fromInteger :: Integer -> Plain :$: a # | |
| Show a => Show (Plain :$: a) Source # | |
| type Trans (Plain a) Source # | |
Defined in DiffLoc.Index | |
Indices bounded by an origin
data IndexFrom (n :: Nat) a Source #
One-dimensional indices with an origin (an initial index). Indices must be greater than the origin, hence the constructor is hidden.
Use indexFromM to construct indices, with TypeApplications to make the
indexing scheme explicit, and fromIndex to destruct them.
(origin :: IndexFrom n a) <= i -- for all i
Instances
indexFromM :: forall n a. (KnownNat n, Num a, Ord a) => a -> Maybe (IndexFrom n a) Source #
Constructor for IndexFrom.
See also indexFrom in DiffLoc.Unsafe, a variant of indexFromM that
throws errors instead of using Maybe.
indexFromM0 :: forall a. (Num a, Ord a) => a -> Maybe (IndexFrom 0 a) Source #
indexFromM specialized to 0-indexing.
indexFromM1 :: forall a. (Num a, Ord a) => a -> Maybe (IndexFrom 1 a) Source #
indexFromM specialized to 1-indexing.
fromIndex0 :: IndexFrom 0 a -> a Source #
fromIndex specialized to 0-indexing.
fromIndex1 :: IndexFrom 1 a -> a Source #
fromIndex specialized to 1-indexing.
zeroIndex :: Num a => IndexFrom 1 a -> IndexFrom 0 a Source #
Convert from one-indexing to zero-indexing.
oneIndex :: Num a => IndexFrom 0 a -> IndexFrom 1 a Source #
Convert from zero-indexing to one-indexing.
Offsets
Type of nonnegative offsets.
Instances
| Num a => Monoid (Offset a) Source # | |
| Num a => Semigroup (Offset a) Source # | |
| Show a => Show (Offset a) Source # | |
| Eq a => Eq (Offset a) Source # | |
| Ord a => Ord (Offset a) Source # | |
Defined in DiffLoc.Index | |
| (Num a, Ord a) => Num (Offset :$: a) Source # | |
Defined in DiffLoc.Starter Methods (+) :: (Offset :$: a) -> (Offset :$: a) -> Offset :$: a # (-) :: (Offset :$: a) -> (Offset :$: a) -> Offset :$: a # (*) :: (Offset :$: a) -> (Offset :$: a) -> Offset :$: a # negate :: (Offset :$: a) -> Offset :$: a # abs :: (Offset :$: a) -> Offset :$: a # signum :: (Offset :$: a) -> Offset :$: a # fromInteger :: Integer -> Offset :$: a # | |
| Show a => Show (Offset :$: a) Source # | |
offsetM :: (Num a, Ord a) => a -> Maybe (Offset a) Source #
Construct a nonnegative Offset.
See also offset in DiffLoc.Unsafe, a variant of offsetM that
throws errors instead of using Maybe.
fromOffset :: Offset a -> a Source #
Unwrap Offset.