/// FunctorM ///
-class (Functor f) => FunctorM f where
+class (FunctorE f) => FunctorM f where
"`mapM f` is equivalent to `sequence . map f`."
- mapM :: Monad m => (a -> m b) -> f a -> m (f b)
+ mapM :: Monad m => (a -> <e> m b) -> f a -> <e> m (f b)
"Evaluate each action in the sequence from left to right, and collect the results."
sequence :: Monad m => f (m a) -> m (f a)
- mapM f l = sequence (fmap f l)
+ mapM f l = sequence (map f l)
/// MonadE ///
"`seq ! i` returns the `i`th element of the sequence `seq`. Indexing starts from zero."
(!) :: f a -> Integer -> a
+"Returns the first element of a sequence"
+@inline
+first l = l!0
+
+"Returns the last element of a sequence"
+@inline
+last l = l!(length l-1)
+
instance IndexedSequence [] where
(!) = getList
Given a list of values and a function computing a key for each value, the function produces a function that finds a value
effeciently for the given key.
"""
- indexBy :: (a -> b) -> [a] -> b -> Maybe a
+ indexBy :: (a -> <e> b) -> [a] -> <e> (b -> Maybe a)
"Works like `index` but uses the given functions as hash codes and equality."
indexWith :: (a -> Integer) -> (a -> a -> Boolean) -> [(a,b)] -> a -> Maybe b