discrete-space-map-0.0.5: A discrete space map.

Data.DiscreteSpaceMap

Synopsis

# Documentation

class Eq p => Pos p where Source #

To be a key in the map, a position needs to be convertible to and from a stream of bits.

Minimal complete definition

Methods

uncons :: p -> (p, Bool) Source #

cons :: (p, Bool) -> p Source #

cons . uncons == id

zero :: p Source #

uncons zero == (zero, False)

Instances

 Source # 1D discrete space Methodsuncons :: Integer -> (Integer, Bool) Source #cons :: (Integer, Bool) -> Integer Source # Pos [Bool] Source # [Bool] is the free instance of Pos. Methodsuncons :: [Bool] -> ([Bool], Bool) Source #cons :: ([Bool], Bool) -> [Bool] Source #zero :: [Bool] Source # Pos p => Pos (p, p) Source # 2D discrete space Methodsuncons :: (p, p) -> ((p, p), Bool) Source #cons :: ((p, p), Bool) -> (p, p) Source #zero :: (p, p) Source # Pos p => Pos (p, p, p) Source # 3D discrete space Methodsuncons :: (p, p, p) -> ((p, p, p), Bool) Source #cons :: ((p, p, p), Bool) -> (p, p, p) Source #zero :: (p, p, p) Source #

data Map p a Source #

Map is a zipper on an infinite perfect binary tree. It contains the position and value of the focus. The other values are stored in the derivative of a perfect binary tree.

Functions that combine 2 maps like zipWith, zipWithKey and <@> preserve the focus position of the second argument.

Constructors

 Map !p !a (MapD a)

Instances

 Pos p => ComonadStore p (Map p) Source #  pos :: Pos p => Map p a -> p peek :: Pos p => p -> Map p a -> a seek :: Pos p => p -> Map p a -> Map p a seeks :: Pos p => (p -> p) -> Map p a -> Map p a Methodspos :: Map p a -> p #peek :: p -> Map p a -> a #peeks :: (p -> p) -> Map p a -> a #seek :: p -> Map p a -> Map p a #seeks :: (p -> p) -> Map p a -> Map p a #experiment :: Functor f => (p -> f p) -> Map p a -> f a # Functor (Map p) Source #  fmap :: (a -> b) -> Map p a -> Map p b Methodsfmap :: (a -> b) -> Map p a -> Map p b #(<\$) :: a -> Map p b -> Map p a # Foldable (Map p) Source #  foldMap :: Monoid m => (a -> m) -> Map p a -> m Methodsfold :: Monoid m => Map p m -> m #foldMap :: Monoid m => (a -> m) -> Map p a -> m #foldr :: (a -> b -> b) -> b -> Map p a -> b #foldr' :: (a -> b -> b) -> b -> Map p a -> b #foldl :: (b -> a -> b) -> b -> Map p a -> b #foldl' :: (b -> a -> b) -> b -> Map p a -> b #foldr1 :: (a -> a -> a) -> Map p a -> a #foldl1 :: (a -> a -> a) -> Map p a -> a #toList :: Map p a -> [a] #null :: Map p a -> Bool #length :: Map p a -> Int #elem :: Eq a => a -> Map p a -> Bool #maximum :: Ord a => Map p a -> a #minimum :: Ord a => Map p a -> a #sum :: Num a => Map p a -> a #product :: Num a => Map p a -> a # Source #  traverse :: Applicative f => (a -> f b) -> Map p a -> f (Map p b) Methodstraverse :: Applicative f => (a -> f b) -> Map p a -> f (Map p b) #sequenceA :: Applicative f => Map p (f a) -> f (Map p a) #mapM :: Monad m => (a -> m b) -> Map p a -> m (Map p b) #sequence :: Monad m => Map p (m a) -> m (Map p a) # Pos p => Distributive (Map p) Source #  distribute :: Functor f => f (Map p a) -> Map p (f a) Methodsdistribute :: Functor f => f (Map p a) -> Map p (f a) #collect :: Functor f => (a -> Map p b) -> f a -> Map p (f b) #distributeM :: Monad m => m (Map p a) -> Map p (m a) #collectM :: Monad m => (a -> Map p b) -> m a -> Map p (m b) # Pos p => Representable (Map p) Source #  index :: Pos p => Map p a -> p -> a tabulate :: Pos p => (p -> a) -> Map p a Associated Typestype Rep (Map p :: * -> *) :: * # Methodstabulate :: (Rep (Map p) -> a) -> Map p a #index :: Map p a -> Rep (Map p) -> a # Comonad (Map p) Source #  extract :: Map p a -> a extend :: (Map p a -> b) -> Map p a -> Map p b Methodsextract :: Map p a -> a #duplicate :: Map p a -> Map p (Map p a) #extend :: (Map p a -> b) -> Map p a -> Map p b # Pos p => ComonadApply (Map p) Source #  (<>) :: Pos p => Map p (a -> b) -> Map p a -> Map p b@ Methods(<@>) :: Map p (a -> b) -> Map p a -> Map p b #(@>) :: Map p a -> Map p b -> Map p b #(<@) :: Map p a -> Map p b -> Map p a # Pos p => Keyed (Map p) Source #  mapWithKey :: Pos p => (p -> a -> b) -> Map p a -> Map p b MethodsmapWithKey :: (Key (Map p) -> a -> b) -> Map p a -> Map p b # Pos p => Zip (Map p) Source #  zipWith :: Pos p => (a -> b -> c) -> Map p a -> Map p b -> Map p c MethodszipWith :: (a -> b -> c) -> Map p a -> Map p b -> Map p c #zip :: Map p a -> Map p b -> Map p (a, b) #zap :: Map p (a -> b) -> Map p a -> Map p b # Pos p => ZipWithKey (Map p) Source #  zipWithKey :: Pos p => (p -> a -> b -> c) -> Map p a -> Map p b -> Map p c MethodszipWithKey :: (Key (Map p) -> a -> b -> c) -> Map p a -> Map p b -> Map p c #zapWithKey :: Map p (Key (Map p) -> a -> b) -> Map p a -> Map p b # Pos p => Indexable (Map p) Source # Methodsindex :: Map p a -> Key (Map p) -> a # Pos p => Lookup (Map p) Source # Methodslookup :: Key (Map p) -> Map p a -> Maybe a # Pos p => Adjustable (Map p) Source # Methodsadjust :: (a -> a) -> Key (Map p) -> Map p a -> Map p a #replace :: Key (Map p) -> a -> Map p a -> Map p a # Pos p => FoldableWithKey (Map p) Source #  foldMapWithKey :: (Pos p, Monoid m) => (p -> a -> m) -> Map p a -> m MethodstoKeyedList :: Map p a -> [(Key (Map p), a)] #foldMapWithKey :: Monoid m => (Key (Map p) -> a -> m) -> Map p a -> m #foldrWithKey :: (Key (Map p) -> a -> b -> b) -> b -> Map p a -> b #foldlWithKey :: (b -> Key (Map p) -> a -> b) -> b -> Map p a -> b # Pos p => FoldableWithKey1 (Map p) Source # MethodsfoldMapWithKey1 :: Semigroup m => (Key (Map p) -> a -> m) -> Map p a -> m # Pos p => TraversableWithKey (Map p) Source #  traverseWithKey :: (Pos p, Applicative f) => (p -> a -> f b) -> Map p a -> f (Map p b) MethodstraverseWithKey :: Applicative f => (Key (Map p) -> a -> f b) -> Map p a -> f (Map p b) #mapWithKeyM :: Monad m => (Key (Map p) -> a -> m b) -> Map p a -> m (Map p b) # Pos p => TraversableWithKey1 (Map p) Source # MethodstraverseWithKey1 :: Apply f => (Key (Map p) -> a -> f b) -> Map p a -> f (Map p b) # Source # Methodstraverse1 :: Apply f => (a -> f b) -> Map p a -> f (Map p b) #sequence1 :: Apply f => Map p (f b) -> f (Map p b) # Foldable1 (Map p) Source # Methodsfold1 :: Semigroup m => Map p m -> m #foldMap1 :: Semigroup m => (a -> m) -> Map p a -> m # (Show a, Show p) => Show (Map p a) Source # MethodsshowsPrec :: Int -> Map p a -> ShowS #show :: Map p a -> String #showList :: [Map p a] -> ShowS # type Rep (Map p) Source # type Rep (Map p) = p type Key (Map p) Source # type Key (Map p) = p

modify :: (a -> a) -> Map p a -> Map p a Source #

Modify the value of the focus.