data-index-0.1.0.0: Extending the concept of indices for lists and other containers
Data.Index
Description
Index, necessary instances for it, end and mid for any container
Index
end
mid
Synopsis
newtype Index t i Source #
This type can contain any container-independent values to be indexed with
Constructors
Fields
Instances
Reader-like Monad instance
Methods
(>>=) :: Index t a -> (a -> Index t b) -> Index t b #
(>>) :: Index t a -> Index t b -> Index t b #
return :: a -> Index t a #
fail :: String -> Index t a #
Reader-like Functor instance
fmap :: (a -> b) -> Index t a -> Index t b #
(<$) :: a -> Index t b -> Index t a #
Reader-like Applicative instance
pure :: a -> Index t a #
(<*>) :: Index t (a -> b) -> Index t a -> Index t b #
liftA2 :: (a -> b -> c) -> Index t a -> Index t b -> Index t c #
(*>) :: Index t a -> Index t b -> Index t b #
(<*) :: Index t a -> Index t b -> Index t a #
Num instance is done via liftA2 and pure
liftA2
pure
(+) :: Index t i -> Index t i -> Index t i #
(-) :: Index t i -> Index t i -> Index t i #
(*) :: Index t i -> Index t i -> Index t i #
negate :: Index t i -> Index t i #
abs :: Index t i -> Index t i #
signum :: Index t i -> Index t i #
fromInteger :: Integer -> Index t i #
run :: t a -> Index t i -> i Source #
Flipped version of runIndex
runIndex
end :: Foldable t => Index t Int Source #
The end of any linear container
mid :: Foldable t => Index t Int Source #
The middle of any linear container