Copyright | (C) 2016-2018 Daniel Wagner 2019 Ryan Scott |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | Ryan Scott |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
An OMap
behaves much like a Map
, with all the same asymptotics, but
also remembers the order that keys were inserted.
This module offers a simplified version of the Data.Map.Ordered.Strict API
that assumes left-biased indices everywhere and uses a different Semigroup
instance (the one in this module uses (
) and <>
) = union
Monoid
instance (the one in this module uses
).mappend
= union
Synopsis
- newtype OMap k v = OMap (Bias L (OMap k v))
- empty :: forall k v. OMap k v
- singleton :: k -> v -> OMap k v
- insertPre :: Ord k => k -> v -> OMap k v -> OMap k v
- insertPost :: Ord k => OMap k v -> k -> v -> OMap k v
- union :: forall k v. Ord k => OMap k v -> OMap k v -> OMap k v
- unionWithKey :: Ord k => (k -> v -> v -> v) -> OMap k v -> OMap k v -> OMap k v
- delete :: forall k v. Ord k => k -> OMap k v -> OMap k v
- filterWithKey :: Ord k => (k -> v -> Bool) -> OMap k v -> OMap k v
- (\\) :: forall k v v'. Ord k => OMap k v -> OMap k v' -> OMap k v
- intersection :: forall k v v'. Ord k => OMap k v -> OMap k v' -> OMap k v
- intersectionWithKey :: Ord k => (k -> v -> v' -> v'') -> OMap k v -> OMap k v' -> OMap k v''
- null :: forall k v. OMap k v -> Bool
- size :: forall k v. OMap k v -> Int
- member :: forall k v. Ord k => k -> OMap k v -> Bool
- notMember :: forall k v. Ord k => k -> OMap k v -> Bool
- lookup :: forall k v. Ord k => k -> OMap k v -> Maybe v
- type Index = Int
- lookupIndex :: forall k v. Ord k => k -> OMap k v -> Maybe Index
- lookupAt :: forall k v. Index -> OMap k v -> Maybe (k, v)
- fromList :: Ord k => [(k, v)] -> OMap k v
- assocs :: forall k v. OMap k v -> [(k, v)]
- toAscList :: forall k v. OMap k v -> [(k, v)]
- toMap :: forall k v. OMap k v -> Map k v
Documentation
An ordered map whose insertPre
, insertPost
, intersection
,
intersectionWithKey
, union
, and unionWithKey
operations are biased
towards leftmost indices when when breaking ties between keys.
Instances
Functor (OMap k) Source # | |
Foldable (OMap k) Source # | |
Defined in Language.Haskell.TH.Desugar.OMap fold :: Monoid m => OMap k m -> m # foldMap :: Monoid m => (a -> m) -> OMap k a -> m # foldr :: (a -> b -> b) -> b -> OMap k a -> b # foldr' :: (a -> b -> b) -> b -> OMap k a -> b # foldl :: (b -> a -> b) -> b -> OMap k a -> b # foldl' :: (b -> a -> b) -> b -> OMap k a -> b # foldr1 :: (a -> a -> a) -> OMap k a -> a # foldl1 :: (a -> a -> a) -> OMap k a -> a # elem :: Eq a => a -> OMap k a -> Bool # maximum :: Ord a => OMap k a -> a # minimum :: Ord a => OMap k a -> a # | |
Ord k => Traversable (OMap k) Source # | |
(Eq k, Eq v) => Eq (OMap k v) Source # | |
(Data k, Data v, Ord k) => Data (OMap k v) Source # | |
Defined in Language.Haskell.TH.Desugar.OMap gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> OMap k v -> c (OMap k v) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (OMap k v) # toConstr :: OMap k v -> Constr # dataTypeOf :: OMap k v -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (OMap k v)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (OMap k v)) # gmapT :: (forall b. Data b => b -> b) -> OMap k v -> OMap k v # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OMap k v -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OMap k v -> r # gmapQ :: (forall d. Data d => d -> u) -> OMap k v -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> OMap k v -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v) # | |
(Ord k, Ord v) => Ord (OMap k v) Source # | |
Defined in Language.Haskell.TH.Desugar.OMap | |
(Ord k, Read k, Read v) => Read (OMap k v) Source # | |
(Show k, Show v) => Show (OMap k v) Source # | |
Ord k => Semigroup (OMap k v) Source # | |
Ord k => Monoid (OMap k v) Source # | |
Trivial maps
Insertion
insertPre :: Ord k => k -> v -> OMap k v -> OMap k v Source #
The value's index will be lower than the indices of the values in the
OSet
.
insertPost :: Ord k => OMap k v -> k -> v -> OMap k v Source #
The value's index will be higher than the indices of the values in the
OSet
.
Deletion
intersectionWithKey :: Ord k => (k -> v -> v' -> v'') -> OMap k v -> OMap k v' -> OMap k v'' Source #
Query
Indexing
A 0-based index, much like the indices used by lists' !!
operation. All
indices are with respect to insertion order.