Copyright | (c) 2014 Patrick Bahr |
---|---|
License | BSD3 |
Maintainer | Patrick Bahr <paba@diku.dk> |
Stability | experimental |
Portability | non-portable (GHC Extensions) |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This module provides functionality to construct mappings from positions in a functorial value.
Synopsis
- data Numbered a = Numbered Int a
- unNumbered :: Numbered a -> a
- number :: Traversable f => f a -> f (Numbered a)
- class (Functor t, Foldable t) => Traversable (t :: Type -> Type)
- class Functor m => Mapping m k | m -> k where
- (&) :: m v -> m v -> m v
- (|->) :: k -> v -> m v
- empty :: m v
- prodMapWith :: (v1 -> v2 -> v) -> v1 -> v2 -> m v1 -> m v2 -> m v
- findWithDefault :: a -> k -> m a -> a
- prodMap :: Mapping m k => v1 -> v2 -> m v1 -> m v2 -> m (v1, v2)
- lookupNumMap :: a -> Int -> NumMap t a -> a
- lookupNumMap' :: Int -> NumMap t a -> Maybe a
- data NumMap k v
Documentation
This type is used for numbering components of a functorial value.
unNumbered :: Numbered a -> a Source #
number :: Traversable f => f a -> f (Numbered a) Source #
This function numbers the components of the given functorial value with consecutive integers starting at 0.
class (Functor t, Foldable t) => Traversable (t :: Type -> Type) #
Functors representing data structures that can be transformed to
structures of the same shape by performing an Applicative
(or,
therefore, Monad
) action on each element from left to right.
A more detailed description of what same shape means, the various methods, how traversals are constructed, and example advanced use-cases can be found in the Overview section of Data.Traversable.
For the class laws see the Laws section of Data.Traversable.
Instances
class Functor m => Mapping m k | m -> k where Source #
(&) :: m v -> m v -> m v infixr 0 Source #
left-biased union of two mappings.
(|->) :: k -> v -> m v infix 1 Source #
This operator constructs a singleton mapping.
This is the empty mapping.
prodMapWith :: (v1 -> v2 -> v) -> v1 -> v2 -> m v1 -> m v2 -> m v Source #
This function constructs the pointwise product of two maps each with a default value.
findWithDefault :: a -> k -> m a -> a Source #
Returns the value at the given key or returns the given default when the key is not an element of the map.
prodMap :: Mapping m k => v1 -> v2 -> m v1 -> m v2 -> m (v1, v2) Source #
This function constructs the pointwise product of two maps each with a default value.
lookupNumMap :: a -> Int -> NumMap t a -> a Source #
Instances
Foldable (NumMap k) Source # | |
Defined in Data.Comp.Mapping fold :: Monoid m => NumMap k m -> m # foldMap :: Monoid m => (a -> m) -> NumMap k a -> m # foldMap' :: Monoid m => (a -> m) -> NumMap k a -> m # foldr :: (a -> b -> b) -> b -> NumMap k a -> b # foldr' :: (a -> b -> b) -> b -> NumMap k a -> b # foldl :: (b -> a -> b) -> b -> NumMap k a -> b # foldl' :: (b -> a -> b) -> b -> NumMap k a -> b # foldr1 :: (a -> a -> a) -> NumMap k a -> a # foldl1 :: (a -> a -> a) -> NumMap k a -> a # elem :: Eq a => a -> NumMap k a -> Bool # maximum :: Ord a => NumMap k a -> a # minimum :: Ord a => NumMap k a -> a # | |
Traversable (NumMap k) Source # | |
Functor (NumMap k) Source # | |
Mapping (NumMap k) (Numbered k) Source # | |
Defined in Data.Comp.Mapping |