data-index-0.1.0.0: Extending the concept of indices for lists and other containers

Safe HaskellSafe
LanguageHaskell2010

Data.Index

Description

Index, necessary instances for it, end and mid for any container

Synopsis

Documentation

newtype Index t i Source #

This type can contain any container-independent values to be indexed with

Constructors

Index 

Fields

Instances

Monad (Index t) Source #

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 #

Functor (Index t) Source #

Reader-like Functor instance

Methods

fmap :: (a -> b) -> Index t a -> Index t b #

(<$) :: a -> Index t b -> Index t a #

Applicative (Index t) Source #

Reader-like Applicative instance

Methods

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 i => Num (Index t i) Source #

Num instance is done via liftA2 and pure

Methods

(+) :: 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

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