brick-2.3.1: A declarative terminal user interface library
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.IMap

Synopsis

Documentation

data IMap a Source #

Semantically, IMap and IntMap are identical; but IMap is more efficient when large sequences of contiguous keys are mapped to the same value.

Instances

Instances details
Applicative IMap Source #

Zippy: (<*>) combines values at equal keys, discarding any values whose key is in only one of its two arguments.

Instance details

Defined in Data.IMap

Methods

pure :: a -> IMap a #

(<*>) :: IMap (a -> b) -> IMap a -> IMap b #

liftA2 :: (a -> b -> c) -> IMap a -> IMap b -> IMap c #

(*>) :: IMap a -> IMap b -> IMap b #

(<*) :: IMap a -> IMap b -> IMap a #

Functor IMap Source # 
Instance details

Defined in Data.IMap

Methods

fmap :: (a -> b) -> IMap a -> IMap b #

(<$) :: a -> IMap b -> IMap a #

Generic (IMap a) Source # 
Instance details

Defined in Data.IMap

Associated Types

type Rep (IMap a) :: Type -> Type #

Methods

from :: IMap a -> Rep (IMap a) x #

to :: Rep (IMap a) x -> IMap a #

Read a => Read (IMap a) Source # 
Instance details

Defined in Data.IMap

Show a => Show (IMap a) Source # 
Instance details

Defined in Data.IMap

Methods

showsPrec :: Int -> IMap a -> ShowS #

show :: IMap a -> String #

showList :: [IMap a] -> ShowS #

NFData a => NFData (IMap a) Source # 
Instance details

Defined in Data.IMap

Methods

rnf :: IMap a -> () #

Eq a => Eq (IMap a) Source # 
Instance details

Defined in Data.IMap

Methods

(==) :: IMap a -> IMap a -> Bool #

(/=) :: IMap a -> IMap a -> Bool #

Ord a => Ord (IMap a) Source # 
Instance details

Defined in Data.IMap

Methods

compare :: IMap a -> IMap a -> Ordering #

(<) :: IMap a -> IMap a -> Bool #

(<=) :: IMap a -> IMap a -> Bool #

(>) :: IMap a -> IMap a -> Bool #

(>=) :: IMap a -> IMap a -> Bool #

max :: IMap a -> IMap a -> IMap a #

min :: IMap a -> IMap a -> IMap a #

type Rep (IMap a) Source # 
Instance details

Defined in Data.IMap

type Rep (IMap a) = D1 ('MetaData "IMap" "Data.IMap" "brick-2.3.1-inplace" 'True) (C1 ('MetaCons "IMap" 'PrefixI 'True) (S1 ('MetaSel ('Just "_runs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (IntMap (Run a)))))

data Run a Source #

Run n a represents n copies of the value a.

Constructors

Run 

Fields

Instances

Instances details
Foldable Run Source # 
Instance details

Defined in Data.IMap

Methods

fold :: Monoid m => Run m -> m #

foldMap :: Monoid m => (a -> m) -> Run a -> m #

foldMap' :: Monoid m => (a -> m) -> Run a -> m #

foldr :: (a -> b -> b) -> b -> Run a -> b #

foldr' :: (a -> b -> b) -> b -> Run a -> b #

foldl :: (b -> a -> b) -> b -> Run a -> b #

foldl' :: (b -> a -> b) -> b -> Run a -> b #

foldr1 :: (a -> a -> a) -> Run a -> a #

foldl1 :: (a -> a -> a) -> Run a -> a #

toList :: Run a -> [a] #

null :: Run a -> Bool #

length :: Run a -> Int #

elem :: Eq a => a -> Run a -> Bool #

maximum :: Ord a => Run a -> a #

minimum :: Ord a => Run a -> a #

sum :: Num a => Run a -> a #

product :: Num a => Run a -> a #

Traversable Run Source # 
Instance details

Defined in Data.IMap

Methods

traverse :: Applicative f => (a -> f b) -> Run a -> f (Run b) #

sequenceA :: Applicative f => Run (f a) -> f (Run a) #

mapM :: Monad m => (a -> m b) -> Run a -> m (Run b) #

sequence :: Monad m => Run (m a) -> m (Run a) #

Functor Run Source # 
Instance details

Defined in Data.IMap

Methods

fmap :: (a -> b) -> Run a -> Run b #

(<$) :: a -> Run b -> Run a #

Generic (Run a) Source # 
Instance details

Defined in Data.IMap

Associated Types

type Rep (Run a) :: Type -> Type #

Methods

from :: Run a -> Rep (Run a) x #

to :: Rep (Run a) x -> Run a #

Read a => Read (Run a) Source # 
Instance details

Defined in Data.IMap

Show a => Show (Run a) Source # 
Instance details

Defined in Data.IMap

Methods

showsPrec :: Int -> Run a -> ShowS #

show :: Run a -> String #

showList :: [Run a] -> ShowS #

NFData a => NFData (Run a) Source # 
Instance details

Defined in Data.IMap

Methods

rnf :: Run a -> () #

Eq a => Eq (Run a) Source # 
Instance details

Defined in Data.IMap

Methods

(==) :: Run a -> Run a -> Bool #

(/=) :: Run a -> Run a -> Bool #

Ord a => Ord (Run a) Source # 
Instance details

Defined in Data.IMap

Methods

compare :: Run a -> Run a -> Ordering #

(<) :: Run a -> Run a -> Bool #

(<=) :: Run a -> Run a -> Bool #

(>) :: Run a -> Run a -> Bool #

(>=) :: Run a -> Run a -> Bool #

max :: Run a -> Run a -> Run a #

min :: Run a -> Run a -> Run a #

type Rep (Run a) Source # 
Instance details

Defined in Data.IMap

type Rep (Run a) = D1 ('MetaData "Run" "Data.IMap" "brick-2.3.1-inplace" 'False) (C1 ('MetaCons "Run" 'PrefixI 'True) (S1 ('MetaSel ('Just "len") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "val") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)))

singleton :: Int -> Run a -> IMap a Source #

insert :: Int -> Run a -> IMap a -> IMap a Source #

delete :: Int -> Run ignored -> IMap a -> IMap a Source #

restrict :: Int -> Run ignored -> IMap a -> IMap a Source #

Given a range of keys (as specified by a starting key and a length for consistency with other functions in this module), restrict the map to keys in that range. restrict k r m is equivalent to intersectionWith const m (insert k r empty) but potentially more efficient.

lookup :: Int -> IMap a -> Maybe a Source #

splitLE :: Int -> IMap a -> (IMap a, IMap a) Source #

splitLE n m produces a tuple (le, gt) where le has all the associations of m where the keys are <= n and gt has all the associations of m where the keys are > n.

intersectionWith :: (a -> b -> c) -> IMap a -> IMap b -> IMap c Source #

mapMaybe :: (a -> Maybe b) -> IMap a -> IMap b Source #

addToKeys :: Int -> IMap a -> IMap a Source #

Increment all keys by the given amount. This is like mapKeysMonotonic, but restricted to partially-applied addition.

unsafeUnion :: IMap a -> IMap a -> IMap a Source #

This function is unsafe because it assumes there is no overlap between its arguments. That is, in the call unsafeUnion a b, the caller must guarantee that if lookup k a = Just v then lookup k b = Nothing and vice versa.

fromList :: [(Int, Run a)] -> IMap a Source #

unsafeRuns :: IMap a -> IntMap (Run a) Source #

This function is unsafe because IMaps that compare equal may split their runs into different chunks; consumers must promise that they do not treat run boundaries specially.

unsafeToAscList :: IMap a -> [(Int, Run a)] Source #

This function is unsafe because IMaps that compare equal may split their runs into different chunks; consumers must promise that they do not treat run boundaries specially.