Copyright | (c) Christopher Davenport 2018 |
---|---|
License | BSD-style |
Maintainer | Chris@ChristopherDavenport.tech |
Portability | portable |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Description
An efficient implementation of non-empty maps from keys to values (dictionaries).
Since many function names (but not the type name) clash with
Prelude names, this module is usually imported qualified
, e.g.
import Data.Map.NonEmpty (NonEmptyMap) import qualified Data.Map.NonEmpty as NonEmptyMap
Synopsis
- data NonEmptyMap k a = NonEmptyMap (k, a) (Map k a)
- singleton :: (k, a) -> NonEmptyMap k a
- fromList :: Ord k => [(k, a)] -> Maybe (NonEmptyMap k a)
- fromListWith :: Ord k => (a -> a -> a) -> [(k, a)] -> Maybe (NonEmptyMap k a)
- fromListWithKey :: Ord k => (k -> a -> a -> a) -> [(k, a)] -> Maybe (NonEmptyMap k a)
- fromNonEmpty :: Ord k => NonEmpty (k, a) -> NonEmptyMap k a
- fromNonEmptyWith :: Ord k => (t -> t -> t) -> NonEmpty (k, t) -> NonEmptyMap k t
- fromNonEmptyWithKey :: Ord k => (k -> a -> a -> a) -> NonEmpty (k, a) -> NonEmptyMap k a
- insert :: Ord k => k -> a -> NonEmptyMap k a -> NonEmptyMap k a
- insertWith :: Ord k => (a -> a -> a) -> k -> a -> NonEmptyMap k a -> NonEmptyMap k a
- insertWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> NonEmptyMap k a -> NonEmptyMap k a
- insertLookupWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> NonEmptyMap k a -> (Maybe a, NonEmptyMap k a)
- delete :: Ord k => k -> NonEmptyMap k a -> Map k a
- adjust :: Ord k => (a -> a) -> k -> NonEmptyMap k a -> NonEmptyMap k a
- update :: Ord k => (a -> Maybe a) -> k -> NonEmptyMap k a -> Map k a
- alter :: Ord k => (Maybe a -> Maybe a) -> k -> NonEmptyMap k a -> Map k a
- alterF :: forall f k a. (Functor f, Ord k) => (Maybe a -> f (Maybe a)) -> k -> NonEmptyMap k a -> f (Map k a)
- lookup :: Ord k => k -> NonEmptyMap k a -> Maybe a
- (!?) :: Ord k => NonEmptyMap k a -> k -> Maybe a
- findWithDefault :: Ord k => a -> k -> NonEmptyMap k a -> a
- member :: Ord k => k -> NonEmptyMap k a -> Bool
- notMember :: Ord k => k -> NonEmptyMap k a -> Bool
- size :: NonEmptyMap k a -> Int
- toList :: NonEmptyMap k a -> [(k, a)]
- toNonEmpty :: NonEmptyMap k a -> NonEmpty (k, a)
- toMap :: Ord k => NonEmptyMap k a -> Map k a
- map :: (t -> b) -> NonEmptyMap k t -> NonEmptyMap k b
- mapWithKey :: (t -> b) -> NonEmptyMap k t -> NonEmptyMap k b
- mapKeys :: Ord k => (t2 -> k) -> NonEmptyMap t2 t1 -> NonEmptyMap k t1
- mapKeysWith :: Ord k => (t1 -> t1 -> t1) -> (t2 -> k) -> NonEmptyMap t2 t1 -> NonEmptyMap k t1
Documentation
data NonEmptyMap k a Source #
A NonEmptyMap of keys k to values a
NonEmptyMap (k, a) (Map k a) |
Instances
Construction
singleton :: (k, a) -> NonEmptyMap k a Source #
fromListWith :: Ord k => (a -> a -> a) -> [(k, a)] -> Maybe (NonEmptyMap k a) Source #
fromListWithKey :: Ord k => (k -> a -> a -> a) -> [(k, a)] -> Maybe (NonEmptyMap k a) Source #
fromNonEmpty :: Ord k => NonEmpty (k, a) -> NonEmptyMap k a Source #
fromNonEmptyWith :: Ord k => (t -> t -> t) -> NonEmpty (k, t) -> NonEmptyMap k t Source #
fromNonEmptyWithKey :: Ord k => (k -> a -> a -> a) -> NonEmpty (k, a) -> NonEmptyMap k a Source #
Insertion
insert :: Ord k => k -> a -> NonEmptyMap k a -> NonEmptyMap k a Source #
insertWith :: Ord k => (a -> a -> a) -> k -> a -> NonEmptyMap k a -> NonEmptyMap k a Source #
insertWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> NonEmptyMap k a -> NonEmptyMap k a Source #
insertLookupWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> NonEmptyMap k a -> (Maybe a, NonEmptyMap k a) Source #
Deletion/Update
adjust :: Ord k => (a -> a) -> k -> NonEmptyMap k a -> NonEmptyMap k a Source #
alterF :: forall f k a. (Functor f, Ord k) => (Maybe a -> f (Maybe a)) -> k -> NonEmptyMap k a -> f (Map k a) Source #
Query
findWithDefault :: Ord k => a -> k -> NonEmptyMap k a -> a Source #
Size
size :: NonEmptyMap k a -> Int Source #
Conversions
toList :: NonEmptyMap k a -> [(k, a)] Source #
toNonEmpty :: NonEmptyMap k a -> NonEmpty (k, a) Source #
Map
map :: (t -> b) -> NonEmptyMap k t -> NonEmptyMap k b Source #
mapWithKey :: (t -> b) -> NonEmptyMap k t -> NonEmptyMap k b Source #
mapKeys :: Ord k => (t2 -> k) -> NonEmptyMap t2 t1 -> NonEmptyMap k t1 Source #
mapKeysWith :: Ord k => (t1 -> t1 -> t1) -> (t2 -> k) -> NonEmptyMap t2 t1 -> NonEmptyMap k t1 Source #