total-maps-1.0.0.3: Dense and sparse total maps.

Data.Total.Map.Subset

Description

Dense, total, maps parametrized by a set of keys.

Synopsis

# Documentation

type Subset s k = Reifies s (Set k) Source #

Subset s k means that s reifies a subset of k.

newtype TotalSubsetMap s k a Source #

A total map from a subset s of keys k to values a, e.g. a restriction of a partial function k -> a to a subset of its domain on which the function is defined.

Most functions are derived from Map.

n is equal to the size of the key set.

Constructors

 TotalSubsetMap (Map k a)

Instances

 Source # Methodsfmap :: (a -> b) -> TotalSubsetMap s k a -> TotalSubsetMap s k b #(<\$) :: a -> TotalSubsetMap s k b -> TotalSubsetMap s k a # (Ord k, Subset s k) => Applicative (TotalSubsetMap s k) Source # Zippy applicative. Complexity: pure O(n), <*> O(n). Methodspure :: a -> TotalSubsetMap s k a #(<*>) :: TotalSubsetMap s k (a -> b) -> TotalSubsetMap s k a -> TotalSubsetMap s k b #(*>) :: TotalSubsetMap s k a -> TotalSubsetMap s k b -> TotalSubsetMap s k b #(<*) :: TotalSubsetMap s k a -> TotalSubsetMap s k b -> TotalSubsetMap s k a # Source # Methodsfold :: Monoid m => TotalSubsetMap s k m -> m #foldMap :: Monoid m => (a -> m) -> TotalSubsetMap s k a -> m #foldr :: (a -> b -> b) -> b -> TotalSubsetMap s k a -> b #foldr' :: (a -> b -> b) -> b -> TotalSubsetMap s k a -> b #foldl :: (b -> a -> b) -> b -> TotalSubsetMap s k a -> b #foldl' :: (b -> a -> b) -> b -> TotalSubsetMap s k a -> b #foldr1 :: (a -> a -> a) -> TotalSubsetMap s k a -> a #foldl1 :: (a -> a -> a) -> TotalSubsetMap s k a -> a #toList :: TotalSubsetMap s k a -> [a] #null :: TotalSubsetMap s k a -> Bool #length :: TotalSubsetMap s k a -> Int #elem :: Eq a => a -> TotalSubsetMap s k a -> Bool #maximum :: Ord a => TotalSubsetMap s k a -> a #minimum :: Ord a => TotalSubsetMap s k a -> a #sum :: Num a => TotalSubsetMap s k a -> a #product :: Num a => TotalSubsetMap s k a -> a # Source # Methodstraverse :: Applicative f => (a -> f b) -> TotalSubsetMap s k a -> f (TotalSubsetMap s k b) #sequenceA :: Applicative f => TotalSubsetMap s k (f a) -> f (TotalSubsetMap s k a) #mapM :: Monad m => (a -> m b) -> TotalSubsetMap s k a -> m (TotalSubsetMap s k b) #sequence :: Monad m => TotalSubsetMap s k (m a) -> m (TotalSubsetMap s k a) # (Ord k, Subset s k) => Distributive (TotalSubsetMap s k) Source # Complexity: distribute O(n * fmap) Methodsdistribute :: Functor f => f (TotalSubsetMap s k a) -> TotalSubsetMap s k (f a) #collect :: Functor f => (a -> TotalSubsetMap s k b) -> f a -> TotalSubsetMap s k (f b) #distributeM :: Monad m => m (TotalSubsetMap s k a) -> TotalSubsetMap s k (m a) #collectM :: Monad m => (a -> TotalSubsetMap s k b) -> m a -> TotalSubsetMap s k (m b) # (Ord k, Subset s k) => Representable (TotalSubsetMap s k) Source # Convert from and to a partial function that would be total if restricted to s.Complexity: tabulate O(n), index O(log n) Associated Typestype Rep (TotalSubsetMap s k :: * -> *) :: * # Methodstabulate :: (Rep (TotalSubsetMap s k) -> a) -> TotalSubsetMap s k a #index :: TotalSubsetMap s k a -> Rep (TotalSubsetMap s k) -> a # (Ord k, Subset s k) => Serial1 (TotalSubsetMap s k) Source # Complexity: serializeWith O(n), deserializeWith O(n * log n) MethodsserializeWith :: MonadPut m => (a -> m ()) -> TotalSubsetMap s k a -> m () #deserializeWith :: MonadGet m => m a -> m (TotalSubsetMap s k a) # Keyed (TotalSubsetMap s k) Source # MethodsmapWithKey :: (Key (TotalSubsetMap s k) -> a -> b) -> TotalSubsetMap s k a -> TotalSubsetMap s k b # Ord k => Zip (TotalSubsetMap s k) Source # MethodszipWith :: (a -> b -> c) -> TotalSubsetMap s k a -> TotalSubsetMap s k b -> TotalSubsetMap s k c #zip :: TotalSubsetMap s k a -> TotalSubsetMap s k b -> TotalSubsetMap s k (a, b) #zap :: TotalSubsetMap s k (a -> b) -> TotalSubsetMap s k a -> TotalSubsetMap s k b # Ord k => ZipWithKey (TotalSubsetMap s k) Source # MethodszipWithKey :: (Key (TotalSubsetMap s k) -> a -> b -> c) -> TotalSubsetMap s k a -> TotalSubsetMap s k b -> TotalSubsetMap s k c #zapWithKey :: TotalSubsetMap s k (Key (TotalSubsetMap s k) -> a -> b) -> TotalSubsetMap s k a -> TotalSubsetMap s k b # Ord k => Indexable (TotalSubsetMap s k) Source # Methodsindex :: TotalSubsetMap s k a -> Key (TotalSubsetMap s k) -> a # Ord k => Lookup (TotalSubsetMap s k) Source # Methodslookup :: Key (TotalSubsetMap s k) -> TotalSubsetMap s k a -> Maybe a # Ord k => Adjustable (TotalSubsetMap s k) Source # Methodsadjust :: (a -> a) -> Key (TotalSubsetMap s k) -> TotalSubsetMap s k a -> TotalSubsetMap s k a #replace :: Key (TotalSubsetMap s k) -> a -> TotalSubsetMap s k a -> TotalSubsetMap s k a # Ord k => FoldableWithKey (TotalSubsetMap s k) Source # MethodstoKeyedList :: TotalSubsetMap s k a -> [(Key (TotalSubsetMap s k), a)] #foldMapWithKey :: Monoid m => (Key (TotalSubsetMap s k) -> a -> m) -> TotalSubsetMap s k a -> m #foldrWithKey :: (Key (TotalSubsetMap s k) -> a -> b -> b) -> b -> TotalSubsetMap s k a -> b #foldlWithKey :: (b -> Key (TotalSubsetMap s k) -> a -> b) -> b -> TotalSubsetMap s k a -> b # Ord k => TraversableWithKey (TotalSubsetMap s k) Source # Complexity: traverseWithKey O(n) MethodstraverseWithKey :: Applicative f => (Key (TotalSubsetMap s k) -> a -> f b) -> TotalSubsetMap s k a -> f (TotalSubsetMap s k b) #mapWithKeyM :: Monad m => (Key (TotalSubsetMap s k) -> a -> m b) -> TotalSubsetMap s k a -> m (TotalSubsetMap s k b) # (Ord k, Subset s k) => Metric (TotalSubsetMap s k) Source # Complexity: all O(n) Methodsdot :: Num a => TotalSubsetMap s k a -> TotalSubsetMap s k a -> a #quadrance :: Num a => TotalSubsetMap s k a -> a #qd :: Num a => TotalSubsetMap s k a -> TotalSubsetMap s k a -> a #distance :: Floating a => TotalSubsetMap s k a -> TotalSubsetMap s k a -> a #norm :: Floating a => TotalSubsetMap s k a -> a #signorm :: Floating a => TotalSubsetMap s k a -> TotalSubsetMap s k a # (Ord k, Subset s k) => Additive (TotalSubsetMap s k) Source # Complexity: all O(n) Methodszero :: Num a => TotalSubsetMap s k a #(^+^) :: Num a => TotalSubsetMap s k a -> TotalSubsetMap s k a -> TotalSubsetMap s k a #(^-^) :: Num a => TotalSubsetMap s k a -> TotalSubsetMap s k a -> TotalSubsetMap s k a #lerp :: Num a => a -> TotalSubsetMap s k a -> TotalSubsetMap s k a -> TotalSubsetMap s k a #liftU2 :: (a -> a -> a) -> TotalSubsetMap s k a -> TotalSubsetMap s k a -> TotalSubsetMap s k a #liftI2 :: (a -> b -> c) -> TotalSubsetMap s k a -> TotalSubsetMap s k b -> TotalSubsetMap s k c # (Eq a, Eq k) => Eq (TotalSubsetMap s k a) Source # Methods(==) :: TotalSubsetMap s k a -> TotalSubsetMap s k a -> Bool #(/=) :: TotalSubsetMap s k a -> TotalSubsetMap s k a -> Bool # (Ord a, Ord k) => Ord (TotalSubsetMap s k a) Source # Methodscompare :: TotalSubsetMap s k a -> TotalSubsetMap s k a -> Ordering #(<) :: TotalSubsetMap s k a -> TotalSubsetMap s k a -> Bool #(<=) :: TotalSubsetMap s k a -> TotalSubsetMap s k a -> Bool #(>) :: TotalSubsetMap s k a -> TotalSubsetMap s k a -> Bool #(>=) :: TotalSubsetMap s k a -> TotalSubsetMap s k a -> Bool #max :: TotalSubsetMap s k a -> TotalSubsetMap s k a -> TotalSubsetMap s k a #min :: TotalSubsetMap s k a -> TotalSubsetMap s k a -> TotalSubsetMap s k a # (Read a, Read k, Ord k) => Read (TotalSubsetMap s k a) Source # MethodsreadsPrec :: Int -> ReadS (TotalSubsetMap s k a) #readList :: ReadS [TotalSubsetMap s k a] #readPrec :: ReadPrec (TotalSubsetMap s k a) #readListPrec :: ReadPrec [TotalSubsetMap s k a] # (Show a, Show k) => Show (TotalSubsetMap s k a) Source # MethodsshowsPrec :: Int -> TotalSubsetMap s k a -> ShowS #show :: TotalSubsetMap s k a -> String #showList :: [TotalSubsetMap s k a] -> ShowS # (Ord k, Subset s k, Serial a) => Serial (TotalSubsetMap s k a) Source # Complexity: serialize O(n), deserialize O(n * log n) Methodsserialize :: MonadPut m => TotalSubsetMap s k a -> m () #deserialize :: MonadGet m => m (TotalSubsetMap s k a) # type Rep (TotalSubsetMap s k) Source # type Rep (TotalSubsetMap s k) = k type Key (TotalSubsetMap s k) Source # type Key (TotalSubsetMap s k) = k

restrict :: forall k a r. Map k a -> (forall s. Subset s k => TotalSubsetMap s k a -> r) -> r Source #

Restrict a partial map to a total map.

Complexity: O(n)