{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveLift #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE TypeFamilies #-}
module Dhall.Map
(
Map
, empty
, singleton
, fromList
, fromListWithKey
, fromMap
, unorderedSingleton
, unorderedFromList
, sort
, isSorted
, insert
, insertWith
, delete
, filter
, partition
, restrictKeys
, withoutKeys
, mapMaybe
, lookup
, member
, uncons
, size
, union
, unionWith
, outerJoin
, intersection
, intersectionWith
, difference
, mapWithKey
, traverseWithKey
, unorderedTraverseWithKey
, unorderedTraverseWithKey_
, foldMapWithKey
, toList
, toAscList
, toMap
, keys
, keysSet
, elems
) where
import Control.Applicative ((<|>))
import Control.DeepSeq (NFData)
import Data.Data (Data)
import GHC.Generics (Generic)
import Instances.TH.Lift ()
import Language.Haskell.TH.Syntax (Lift)
import Prelude hiding (filter, lookup)
import qualified Data.List
import qualified Data.Map
import qualified Data.Set
import qualified GHC.Exts
import qualified Prelude
data Map k v = Map (Data.Map.Map k v) (Keys k)
deriving (Map k v -> DataType
Map k v -> Constr
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall {k} {v}. (Data k, Data v, Ord k) => Typeable (Map k v)
forall k v. (Data k, Data v, Ord k) => Map k v -> DataType
forall k v. (Data k, Data v, Ord k) => Map k v -> Constr
forall k v.
(Data k, Data v, Ord k) =>
(forall b. Data b => b -> b) -> Map k v -> Map k v
forall k v u.
(Data k, Data v, Ord k) =>
Int -> (forall d. Data d => d -> u) -> Map k v -> u
forall k v u.
(Data k, Data v, Ord k) =>
(forall d. Data d => d -> u) -> Map k v -> [u]
forall k v r r'.
(Data k, Data v, Ord k) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Map k v -> r
forall k v r r'.
(Data k, Data v, Ord k) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Map k v -> r
forall k v (m :: * -> *).
(Data k, Data v, Ord k, Monad m) =>
(forall d. Data d => d -> m d) -> Map k v -> m (Map k v)
forall k v (m :: * -> *).
(Data k, Data v, Ord k, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Map k v -> m (Map k v)
forall k v (c :: * -> *).
(Data k, Data v, Ord k) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Map k v)
forall k v (c :: * -> *).
(Data k, Data v, Ord k) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Map k v -> c (Map k v)
forall k v (t :: * -> *) (c :: * -> *).
(Data k, Data v, Ord k, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Map k v))
forall k v (t :: * -> * -> *) (c :: * -> *).
(Data k, Data v, Ord k, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Map k v))
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Map k v)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Map k v -> c (Map k v)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Map k v))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Map k v -> m (Map k v)
$cgmapMo :: forall k v (m :: * -> *).
(Data k, Data v, Ord k, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Map k v -> m (Map k v)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Map k v -> m (Map k v)
$cgmapMp :: forall k v (m :: * -> *).
(Data k, Data v, Ord k, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Map k v -> m (Map k v)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Map k v -> m (Map k v)
$cgmapM :: forall k v (m :: * -> *).
(Data k, Data v, Ord k, Monad m) =>
(forall d. Data d => d -> m d) -> Map k v -> m (Map k v)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Map k v -> u
$cgmapQi :: forall k v u.
(Data k, Data v, Ord k) =>
Int -> (forall d. Data d => d -> u) -> Map k v -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Map k v -> [u]
$cgmapQ :: forall k v u.
(Data k, Data v, Ord k) =>
(forall d. Data d => d -> u) -> Map k v -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Map k v -> r
$cgmapQr :: forall k v r r'.
(Data k, Data v, Ord k) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Map k v -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Map k v -> r
$cgmapQl :: forall k v r r'.
(Data k, Data v, Ord k) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Map k v -> r
gmapT :: (forall b. Data b => b -> b) -> Map k v -> Map k v
$cgmapT :: forall k v.
(Data k, Data v, Ord k) =>
(forall b. Data b => b -> b) -> Map k v -> Map k v
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Map k v))
$cdataCast2 :: forall k v (t :: * -> * -> *) (c :: * -> *).
(Data k, Data v, Ord k, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Map k v))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Map k v))
$cdataCast1 :: forall k v (t :: * -> *) (c :: * -> *).
(Data k, Data v, Ord k, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Map k v))
dataTypeOf :: Map k v -> DataType
$cdataTypeOf :: forall k v. (Data k, Data v, Ord k) => Map k v -> DataType
toConstr :: Map k v -> Constr
$ctoConstr :: forall k v. (Data k, Data v, Ord k) => Map k v -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Map k v)
$cgunfold :: forall k v (c :: * -> *).
(Data k, Data v, Ord k) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Map k v)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Map k v -> c (Map k v)
$cgfoldl :: forall k v (c :: * -> *).
(Data k, Data v, Ord k) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Map k v -> c (Map k v)
Data, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall k v x. Rep (Map k v) x -> Map k v
forall k v x. Map k v -> Rep (Map k v) x
$cto :: forall k v x. Rep (Map k v) x -> Map k v
$cfrom :: forall k v x. Map k v -> Rep (Map k v) x
Generic, forall k v (m :: * -> *).
(Lift k, Lift v, Quote m) =>
Map k v -> m Exp
forall k v (m :: * -> *).
(Lift k, Lift v, Quote m) =>
Map k v -> Code m (Map k v)
forall t.
(forall (m :: * -> *). Quote m => t -> m Exp)
-> (forall (m :: * -> *). Quote m => t -> Code m t) -> Lift t
forall (m :: * -> *). Quote m => Map k v -> m Exp
forall (m :: * -> *). Quote m => Map k v -> Code m (Map k v)
liftTyped :: forall (m :: * -> *). Quote m => Map k v -> Code m (Map k v)
$cliftTyped :: forall k v (m :: * -> *).
(Lift k, Lift v, Quote m) =>
Map k v -> Code m (Map k v)
lift :: forall (m :: * -> *). Quote m => Map k v -> m Exp
$clift :: forall k v (m :: * -> *).
(Lift k, Lift v, Quote m) =>
Map k v -> m Exp
Lift, forall a. (a -> ()) -> NFData a
forall k v. (NFData k, NFData v) => Map k v -> ()
rnf :: Map k v -> ()
$crnf :: forall k v. (NFData k, NFData v) => Map k v -> ()
NFData)
data Keys a
= Sorted
| Original [a]
deriving (Keys a -> DataType
Keys a -> Constr
forall {a}. Data a => Typeable (Keys a)
forall a. Data a => Keys a -> DataType
forall a. Data a => Keys a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> Keys a -> Keys a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Keys a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> Keys a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Keys a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Keys a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Keys a -> m (Keys a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Keys a -> m (Keys a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Keys a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Keys a -> c (Keys a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Keys a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Keys a))
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Keys a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Keys a -> c (Keys a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Keys a))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Keys a -> m (Keys a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Keys a -> m (Keys a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Keys a -> m (Keys a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Keys a -> m (Keys a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Keys a -> m (Keys a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Keys a -> m (Keys a)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Keys a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Keys a -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Keys a -> [u]
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> Keys a -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Keys a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Keys a -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Keys a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Keys a -> r
gmapT :: (forall b. Data b => b -> b) -> Keys a -> Keys a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> Keys a -> Keys a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Keys a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Keys a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Keys a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Keys a))
dataTypeOf :: Keys a -> DataType
$cdataTypeOf :: forall a. Data a => Keys a -> DataType
toConstr :: Keys a -> Constr
$ctoConstr :: forall a. Data a => Keys a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Keys a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Keys a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Keys a -> c (Keys a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Keys a -> c (Keys a)
Data, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Keys a) x -> Keys a
forall a x. Keys a -> Rep (Keys a) x
$cto :: forall a x. Rep (Keys a) x -> Keys a
$cfrom :: forall a x. Keys a -> Rep (Keys a) x
Generic, forall a (m :: * -> *). (Lift a, Quote m) => Keys a -> m Exp
forall a (m :: * -> *).
(Lift a, Quote m) =>
Keys a -> Code m (Keys a)
forall t.
(forall (m :: * -> *). Quote m => t -> m Exp)
-> (forall (m :: * -> *). Quote m => t -> Code m t) -> Lift t
forall (m :: * -> *). Quote m => Keys a -> m Exp
forall (m :: * -> *). Quote m => Keys a -> Code m (Keys a)
liftTyped :: forall (m :: * -> *). Quote m => Keys a -> Code m (Keys a)
$cliftTyped :: forall a (m :: * -> *).
(Lift a, Quote m) =>
Keys a -> Code m (Keys a)
lift :: forall (m :: * -> *). Quote m => Keys a -> m Exp
$clift :: forall a (m :: * -> *). (Lift a, Quote m) => Keys a -> m Exp
Lift, forall a. NFData a => Keys a -> ()
forall a. (a -> ()) -> NFData a
rnf :: Keys a -> ()
$crnf :: forall a. NFData a => Keys a -> ()
NFData)
instance (Ord k, Eq v) => Eq (Map k v) where
Map k v
m1 == :: Map k v -> Map k v -> Bool
== Map k v
m2 =
forall k a. Map k a -> Int
Data.Map.size (forall k v. Map k v -> Map k v
toMap Map k v
m1) forall a. Eq a => a -> a -> Bool
== forall k a. Map k a -> Int
Data.Map.size (forall k v. Map k v -> Map k v
toMap Map k v
m2)
Bool -> Bool -> Bool
&& forall k v. Ord k => Map k v -> [(k, v)]
toList Map k v
m1 forall a. Eq a => a -> a -> Bool
== forall k v. Ord k => Map k v -> [(k, v)]
toList Map k v
m2
{-# INLINABLE (==) #-}
instance (Ord k, Ord v) => Ord (Map k v) where
compare :: Map k v -> Map k v -> Ordering
compare Map k v
m1 Map k v
m2 = forall a. Ord a => a -> a -> Ordering
compare (forall k v. Ord k => Map k v -> [(k, v)]
toList Map k v
m1) (forall k v. Ord k => Map k v -> [(k, v)]
toList Map k v
m2)
{-# INLINABLE compare #-}
instance Functor (Map k) where
fmap :: forall a b. (a -> b) -> Map k a -> Map k b
fmap a -> b
f (Map Map k a
m Keys k
ks) = forall k v. Map k v -> Keys k -> Map k v
Map (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Map k a
m) Keys k
ks
{-# INLINABLE fmap #-}
instance Ord k => Foldable (Map k) where
foldr :: forall a b. (a -> b -> b) -> b -> Map k a -> b
foldr a -> b -> b
f b
z (Map Map k a
m Keys k
Sorted) = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr a -> b -> b
f b
z Map k a
m
foldr a -> b -> b
f b
z Map k a
m = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr a -> b -> b
f b
z (forall k v. Ord k => Map k v -> [v]
elems Map k a
m)
{-# INLINABLE foldr #-}
length :: forall a. Map k a -> Int
length Map k a
m = forall k v. Map k v -> Int
size Map k a
m
{-# INLINABLE length #-}
null :: forall a. Map k a -> Bool
null (Map Map k a
m Keys k
_) = forall (t :: * -> *) a. Foldable t => t a -> Bool
null Map k a
m
{-# INLINABLE null #-}
instance Ord k => Traversable (Map k) where
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Map k a -> f (Map k b)
traverse a -> f b
f Map k a
m = forall k (f :: * -> *) a b.
(Ord k, Applicative f) =>
(k -> a -> f b) -> Map k a -> f (Map k b)
traverseWithKey (\k
_ a
v -> a -> f b
f a
v) Map k a
m
{-# INLINABLE traverse #-}
instance Ord k => Semigroup (Map k v) where
<> :: Map k v -> Map k v -> Map k v
(<>) = forall k v. Ord k => Map k v -> Map k v -> Map k v
union
{-# INLINABLE (<>) #-}
instance Ord k => Monoid (Map k v) where
mempty :: Map k v
mempty = forall k v. Map k v -> Keys k -> Map k v
Map forall k a. Map k a
Data.Map.empty (forall a. [a] -> Keys a
Original [])
{-# INLINABLE mempty #-}
instance (Show k, Show v, Ord k) => Show (Map k v) where
showsPrec :: Int -> Map k v -> ShowS
showsPrec Int
d Map k v
m =
Bool -> ShowS -> ShowS
showParen (Int
d forall a. Ord a => a -> a -> Bool
> Int
10) (String -> ShowS
showString String
"fromList " forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 [(k, v)]
kvs)
where
kvs :: [(k, v)]
kvs = forall k v. Ord k => Map k v -> [(k, v)]
toList Map k v
m
instance Ord k => GHC.Exts.IsList (Map k v) where
type Item (Map k v) = (k, v)
fromList :: [Item (Map k v)] -> Map k v
fromList = forall k v. Ord k => [(k, v)] -> Map k v
Dhall.Map.fromList
toList :: Map k v -> [Item (Map k v)]
toList = forall k v. Ord k => Map k v -> [(k, v)]
Dhall.Map.toList
empty :: Ord k => Map k v
empty :: forall k v. Ord k => Map k v
empty = forall a. Monoid a => a
mempty
singleton :: k -> v -> Map k v
singleton :: forall k v. k -> v -> Map k v
singleton k
k v
v = forall k v. Map k v -> Keys k -> Map k v
Map Map k v
m Keys k
ks
where
m :: Map k v
m = forall k a. k -> a -> Map k a
Data.Map.singleton k
k v
v
ks :: Keys k
ks = forall a. [a] -> Keys a
Original [k
k]
{-# INLINABLE singleton #-}
fromList :: Ord k => [(k, v)] -> Map k v
fromList :: forall k v. Ord k => [(k, v)] -> Map k v
fromList [(k, v)]
kvs = forall k v. Map k v -> Keys k -> Map k v
Map Map k v
m Keys k
ks
where
m :: Map k v
m = forall k a. Ord k => [(k, a)] -> Map k a
Data.Map.fromList [(k, v)]
kvs
ks :: Keys k
ks = forall a. [a] -> Keys a
Original (forall k. Ord k => [k] -> [k]
nubOrd (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst [(k, v)]
kvs))
{-# INLINABLE fromList #-}
fromListWithKey :: Ord k => (k -> v -> v -> v) -> [(k, v)] -> Map k v
fromListWithKey :: forall k v. Ord k => (k -> v -> v -> v) -> [(k, v)] -> Map k v
fromListWithKey k -> v -> v -> v
f [(k, v)]
kvs = forall k v. Map k v -> Keys k -> Map k v
Map Map k v
m Keys k
ks
where
m :: Map k v
m = forall k a. Ord k => (k -> a -> a -> a) -> [(k, a)] -> Map k a
Data.Map.fromListWithKey k -> v -> v -> v
f [(k, v)]
kvs
ks :: Keys k
ks = forall a. [a] -> Keys a
Original (forall k. Ord k => [k] -> [k]
nubOrd (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst [(k, v)]
kvs))
{-# INLINABLE fromListWithKey #-}
fromMap :: Data.Map.Map k v -> Map k v
fromMap :: forall k v. Map k v -> Map k v
fromMap Map k v
m = forall k v. Map k v -> Keys k -> Map k v
Map Map k v
m forall a. Keys a
Sorted
nubOrd :: Ord k => [k] -> [k]
nubOrd :: forall k. Ord k => [k] -> [k]
nubOrd = forall {a}. Ord a => Set a -> [a] -> [a]
go forall a. Set a
Data.Set.empty
where
go :: Set a -> [a] -> [a]
go Set a
_ [] = []
go Set a
set (a
k:[a]
ks)
| forall a. Ord a => a -> Set a -> Bool
Data.Set.member a
k Set a
set = Set a -> [a] -> [a]
go Set a
set [a]
ks
| Bool
otherwise = a
k forall a. a -> [a] -> [a]
: Set a -> [a] -> [a]
go (forall a. Ord a => a -> Set a -> Set a
Data.Set.insert a
k Set a
set) [a]
ks
{-# INLINABLE nubOrd #-}
unorderedSingleton :: k -> v -> Map k v
unorderedSingleton :: forall k v. k -> v -> Map k v
unorderedSingleton k
k v
v = forall k v. Map k v -> Keys k -> Map k v
Map Map k v
m forall a. Keys a
Sorted
where
m :: Map k v
m = forall k a. k -> a -> Map k a
Data.Map.singleton k
k v
v
{-# INLINABLE unorderedSingleton #-}
unorderedFromList :: Ord k => [(k, v)] -> Map k v
unorderedFromList :: forall k v. Ord k => [(k, v)] -> Map k v
unorderedFromList [(k, v)]
kvs = forall k v. Map k v -> Keys k -> Map k v
Map Map k v
m forall a. Keys a
Sorted
where
m :: Map k v
m = forall k a. Ord k => [(k, a)] -> Map k a
Data.Map.fromList [(k, v)]
kvs
{-# INLINABLE unorderedFromList #-}
sort :: Map k v -> Map k v
sort :: forall k v. Map k v -> Map k v
sort (Map Map k v
m Keys k
_) = forall k v. Map k v -> Keys k -> Map k v
Map Map k v
m forall a. Keys a
Sorted
{-# INLINABLE sort #-}
isSorted :: Eq k => Map k v -> Bool
isSorted :: forall k v. Eq k => Map k v -> Bool
isSorted (Map Map k v
_ Keys k
Sorted) = Bool
True
isSorted (Map Map k v
m (Original [k]
ks)) = forall k a. Map k a -> [k]
Data.Map.keys Map k v
m forall a. Eq a => a -> a -> Bool
== [k]
ks
{-# INLINABLE isSorted #-}
insert :: Ord k => k -> v -> Map k v -> Map k v
insert :: forall k v. Ord k => k -> v -> Map k v -> Map k v
insert k
k v
v (Map Map k v
m Keys k
Sorted) = forall k v. Map k v -> Keys k -> Map k v
Map (forall k a. Ord k => k -> a -> Map k a -> Map k a
Data.Map.insert k
k v
v Map k v
m) forall a. Keys a
Sorted
insert k
k v
v (Map Map k v
m (Original [k]
ks)) = forall k v. Map k v -> Keys k -> Map k v
Map Map k v
m' (forall a. [a] -> Keys a
Original [k]
ks')
where
(Maybe v
mayOldV, Map k v
m') = forall k a.
Ord k =>
(k -> a -> a -> a) -> k -> a -> Map k a -> (Maybe a, Map k a)
Data.Map.insertLookupWithKey (\k
_k v
new v
_old -> v
new) k
k v
v Map k v
m
ks' :: [k]
ks' | Just v
_ <- Maybe v
mayOldV = [k]
ks
| Bool
otherwise = k
k forall a. a -> [a] -> [a]
: [k]
ks
{-# INLINABLE insert #-}
insertWith :: Ord k => (v -> v -> v) -> k -> v -> Map k v -> Map k v
insertWith :: forall k v. Ord k => (v -> v -> v) -> k -> v -> Map k v -> Map k v
insertWith v -> v -> v
f k
k v
v (Map Map k v
m Keys k
Sorted) = forall k v. Map k v -> Keys k -> Map k v
Map (forall k a. Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a
Data.Map.insertWith v -> v -> v
f k
k v
v Map k v
m) forall a. Keys a
Sorted
insertWith v -> v -> v
f k
k v
v (Map Map k v
m (Original [k]
ks)) = forall k v. Map k v -> Keys k -> Map k v
Map Map k v
m' (forall a. [a] -> Keys a
Original [k]
ks')
where
(Maybe v
mayOldV, Map k v
m') = forall k a.
Ord k =>
(k -> a -> a -> a) -> k -> a -> Map k a -> (Maybe a, Map k a)
Data.Map.insertLookupWithKey (\k
_k v
new v
old -> v -> v -> v
f v
new v
old) k
k v
v Map k v
m
ks' :: [k]
ks' | Just v
_ <- Maybe v
mayOldV = [k]
ks
| Bool
otherwise = k
k forall a. a -> [a] -> [a]
: [k]
ks
{-# INLINABLE insertWith #-}
delete :: Ord k => k -> Map k v -> Map k v
delete :: forall k v. Ord k => k -> Map k v -> Map k v
delete k
k (Map Map k v
m Keys k
ks) = forall k v. Map k v -> Keys k -> Map k v
Map Map k v
m' Keys k
ks'
where
m' :: Map k v
m' = forall k a. Ord k => k -> Map k a -> Map k a
Data.Map.delete k
k Map k v
m
ks' :: Keys k
ks' = case Keys k
ks of
Keys k
Sorted -> forall a. Keys a
Sorted
Original [k]
ks'' -> forall a. [a] -> Keys a
Original (forall a. Eq a => a -> [a] -> [a]
Data.List.delete k
k [k]
ks'')
{-# INLINABLE delete #-}
filter :: Ord k => (a -> Bool) -> Map k a -> Map k a
filter :: forall k a. Ord k => (a -> Bool) -> Map k a -> Map k a
filter a -> Bool
predicate (Map Map k a
m Keys k
ks) = forall k v. Map k v -> Keys k -> Map k v
Map Map k a
m' Keys k
ks'
where
m' :: Map k a
m' = forall a k. (a -> Bool) -> Map k a -> Map k a
Data.Map.filter a -> Bool
predicate Map k a
m
ks' :: Keys k
ks' = forall a. (a -> Bool) -> Keys a -> Keys a
filterKeys (\k
k -> forall k a. Ord k => k -> Map k a -> Bool
Data.Map.member k
k Map k a
m') Keys k
ks
{-# INLINABLE filter #-}
partition :: Ord k => (a -> Bool) -> Map k a -> (Map k a, Map k a)
partition :: forall k a. Ord k => (a -> Bool) -> Map k a -> (Map k a, Map k a)
partition a -> Bool
predicate (Map Map k a
m Keys k
ks) = (forall k v. Map k v -> Keys k -> Map k v
Map Map k a
mpass Keys k
kpass, forall k v. Map k v -> Keys k -> Map k v
Map Map k a
mfail Keys k
kfail)
where
(Map k a
mpass, Map k a
mfail) = forall a k. (a -> Bool) -> Map k a -> (Map k a, Map k a)
Data.Map.partition a -> Bool
predicate Map k a
m
(Keys k
kpass, Keys k
kfail) = forall a. (a -> Bool) -> Keys a -> (Keys a, Keys a)
partitionKeys (\k
k -> forall k a. Ord k => k -> Map k a -> Bool
Data.Map.member k
k Map k a
mpass) Keys k
ks
{-# INLINABLE partition #-}
restrictKeys :: Ord k => Map k a -> Data.Set.Set k -> Map k a
restrictKeys :: forall k a. Ord k => Map k a -> Set k -> Map k a
restrictKeys (Map Map k a
m Keys k
ks) Set k
s = forall k v. Map k v -> Keys k -> Map k v
Map Map k a
m' Keys k
ks'
where
m' :: Map k a
m' = forall k a. Ord k => Map k a -> Set k -> Map k a
Data.Map.restrictKeys Map k a
m Set k
s
ks' :: Keys k
ks' = forall a. (a -> Bool) -> Keys a -> Keys a
filterKeys (\k
k -> forall a. Ord a => a -> Set a -> Bool
Data.Set.member k
k Set k
s) Keys k
ks
{-# INLINABLE restrictKeys #-}
withoutKeys :: Ord k => Map k a -> Data.Set.Set k -> Map k a
withoutKeys :: forall k a. Ord k => Map k a -> Set k -> Map k a
withoutKeys (Map Map k a
m Keys k
ks) Set k
s = forall k v. Map k v -> Keys k -> Map k v
Map Map k a
m' Keys k
ks'
where
m' :: Map k a
m' = forall k a. Ord k => Map k a -> Set k -> Map k a
Data.Map.withoutKeys Map k a
m Set k
s
ks' :: Keys k
ks' = forall a. (a -> Bool) -> Keys a -> Keys a
filterKeys (\k
k -> forall a. Ord a => a -> Set a -> Bool
Data.Set.notMember k
k Set k
s) Keys k
ks
{-# INLINABLE withoutKeys #-}
mapMaybe :: Ord k => (a -> Maybe b) -> Map k a -> Map k b
mapMaybe :: forall k a b. Ord k => (a -> Maybe b) -> Map k a -> Map k b
mapMaybe a -> Maybe b
f (Map Map k a
m Keys k
ks) = forall k v. Map k v -> Keys k -> Map k v
Map Map k b
m' Keys k
ks'
where
m' :: Map k b
m' = forall a b k. (a -> Maybe b) -> Map k a -> Map k b
Data.Map.mapMaybe a -> Maybe b
f Map k a
m
ks' :: Keys k
ks' = forall a. (a -> Bool) -> Keys a -> Keys a
filterKeys (\k
k -> forall k a. Ord k => k -> Map k a -> Bool
Data.Map.member k
k Map k b
m') Keys k
ks
{-# INLINABLE mapMaybe #-}
lookup :: Ord k => k -> Map k v -> Maybe v
lookup :: forall k v. Ord k => k -> Map k v -> Maybe v
lookup k
k (Map Map k v
m Keys k
_) = forall k a. Ord k => k -> Map k a -> Maybe a
Data.Map.lookup k
k Map k v
m
{-# INLINABLE lookup #-}
uncons :: Ord k => Map k v -> Maybe (k, v, Map k v)
uncons :: forall k v. Ord k => Map k v -> Maybe (k, v, Map k v)
uncons (Map Map k v
_ (Original [])) = forall a. Maybe a
Nothing
uncons (Map Map k v
m (Original (k
k:[k]
ks))) =
forall a. a -> Maybe a
Just (k
k, Map k v
m forall k a. Ord k => Map k a -> k -> a
Data.Map.! k
k, forall k v. Map k v -> Keys k -> Map k v
Map (forall k a. Ord k => k -> Map k a -> Map k a
Data.Map.delete k
k Map k v
m) (forall a. [a] -> Keys a
Original [k]
ks))
uncons (Map Map k v
m Keys k
Sorted)
| Just ((k
k, v
v), Map k v
m') <- forall k a. Map k a -> Maybe ((k, a), Map k a)
Data.Map.minViewWithKey Map k v
m = forall a. a -> Maybe a
Just (k
k, v
v, forall k v. Map k v -> Keys k -> Map k v
Map Map k v
m' forall a. Keys a
Sorted)
| Bool
otherwise = forall a. Maybe a
Nothing
{-# INLINABLE uncons #-}
member :: Ord k => k -> Map k v -> Bool
member :: forall k v. Ord k => k -> Map k v -> Bool
member k
k (Map Map k v
m Keys k
_) = forall k a. Ord k => k -> Map k a -> Bool
Data.Map.member k
k Map k v
m
{-# INLINABLE member #-}
size :: Map k v -> Int
size :: forall k v. Map k v -> Int
size (Map Map k v
m Keys k
_) = forall k a. Map k a -> Int
Data.Map.size Map k v
m
{-# INLINABLE size #-}
union :: Ord k => Map k v -> Map k v -> Map k v
union :: forall k v. Ord k => Map k v -> Map k v -> Map k v
union (Map Map k v
mL Keys k
ksL) (Map Map k v
mR Keys k
ksR) = forall k v. Map k v -> Keys k -> Map k v
Map Map k v
m Keys k
ks
where
m :: Map k v
m = forall k a. Ord k => Map k a -> Map k a -> Map k a
Data.Map.union Map k v
mL Map k v
mR
ks :: Keys k
ks = case (Keys k
ksL, Keys k
ksR) of
(Original [k]
l, Original [k]
r) -> forall a. [a] -> Keys a
Original forall a b. (a -> b) -> a -> b
$
[k]
l forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall a. (a -> Bool) -> [a] -> [a]
Prelude.filter (\k
k -> forall k a. Ord k => k -> Map k a -> Bool
Data.Map.notMember k
k Map k v
mL) [k]
r
(Keys k, Keys k)
_ -> forall a. Keys a
Sorted
{-# INLINABLE union #-}
unionWith :: Ord k => (v -> v -> v) -> Map k v -> Map k v -> Map k v
unionWith :: forall k v. Ord k => (v -> v -> v) -> Map k v -> Map k v -> Map k v
unionWith v -> v -> v
combine (Map Map k v
mL Keys k
ksL) (Map Map k v
mR Keys k
ksR) = forall k v. Map k v -> Keys k -> Map k v
Map Map k v
m Keys k
ks
where
m :: Map k v
m = forall k a. Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a
Data.Map.unionWith v -> v -> v
combine Map k v
mL Map k v
mR
ks :: Keys k
ks = case (Keys k
ksL, Keys k
ksR) of
(Original [k]
l, Original [k]
r) -> forall a. [a] -> Keys a
Original forall a b. (a -> b) -> a -> b
$
[k]
l forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall a. (a -> Bool) -> [a] -> [a]
Prelude.filter (\k
k -> forall k a. Ord k => k -> Map k a -> Bool
Data.Map.notMember k
k Map k v
mL) [k]
r
(Keys k, Keys k)
_ -> forall a. Keys a
Sorted
{-# INLINABLE unionWith #-}
outerJoin
:: Ord k
=> (a -> c)
-> (b -> c)
-> (k -> a -> b -> c)
-> Map k a
-> Map k b
-> Map k c
outerJoin :: forall k a c b.
Ord k =>
(a -> c)
-> (b -> c) -> (k -> a -> b -> c) -> Map k a -> Map k b -> Map k c
outerJoin a -> c
fa b -> c
fb k -> a -> b -> c
fab (Map Map k a
ma Keys k
ksA) (Map Map k b
mb Keys k
ksB) = forall k v. Map k v -> Keys k -> Map k v
Map Map k c
m Keys k
ks
where
m :: Map k c
m = forall k a b c.
Ord k =>
(k -> a -> b -> Maybe c)
-> (Map k a -> Map k c)
-> (Map k b -> Map k c)
-> Map k a
-> Map k b
-> Map k c
Data.Map.mergeWithKey
(\k
k a
a b
b -> forall a. a -> Maybe a
Just (k -> a -> b -> c
fab k
k a
a b
b))
(forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> c
fa)
(forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> c
fb)
Map k a
ma
Map k b
mb
ks :: Keys k
ks = case (Keys k
ksA, Keys k
ksB) of
(Original [k]
l, Original [k]
r) -> forall a. [a] -> Keys a
Original forall a b. (a -> b) -> a -> b
$
[k]
l forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall a. (a -> Bool) -> [a] -> [a]
Prelude.filter (\k
k -> forall k a. Ord k => k -> Map k a -> Bool
Data.Map.notMember k
k Map k a
ma) [k]
r
(Keys k, Keys k)
_ -> forall a. Keys a
Sorted
{-# INLINABLE outerJoin #-}
intersection :: Ord k => Map k a -> Map k b -> Map k a
intersection :: forall k a b. Ord k => Map k a -> Map k b -> Map k a
intersection (Map Map k a
mL Keys k
ksL) (Map Map k b
mR Keys k
_) = forall k v. Map k v -> Keys k -> Map k v
Map Map k a
m Keys k
ks
where
m :: Map k a
m = forall k a b. Ord k => Map k a -> Map k b -> Map k a
Data.Map.intersection Map k a
mL Map k b
mR
ks :: Keys k
ks = forall a. (a -> Bool) -> Keys a -> Keys a
filterKeys (\k
k -> forall k a. Ord k => k -> Map k a -> Bool
Data.Map.member k
k Map k a
m) Keys k
ksL
{-# INLINABLE intersection #-}
intersectionWith :: Ord k => (a -> b -> c) -> Map k a -> Map k b -> Map k c
intersectionWith :: forall k a b c.
Ord k =>
(a -> b -> c) -> Map k a -> Map k b -> Map k c
intersectionWith a -> b -> c
combine (Map Map k a
mL Keys k
ksL) (Map Map k b
mR Keys k
_) = forall k v. Map k v -> Keys k -> Map k v
Map Map k c
m Keys k
ks
where
m :: Map k c
m = forall k a b c.
Ord k =>
(a -> b -> c) -> Map k a -> Map k b -> Map k c
Data.Map.intersectionWith a -> b -> c
combine Map k a
mL Map k b
mR
ks :: Keys k
ks = forall a. (a -> Bool) -> Keys a -> Keys a
filterKeys (\k
k -> forall k a. Ord k => k -> Map k a -> Bool
Data.Map.member k
k Map k c
m) Keys k
ksL
{-# INLINABLE intersectionWith #-}
difference :: Ord k => Map k a -> Map k b -> Map k a
difference :: forall k a b. Ord k => Map k a -> Map k b -> Map k a
difference (Map Map k a
mL Keys k
ksL) (Map Map k b
mR Keys k
_) = forall k v. Map k v -> Keys k -> Map k v
Map Map k a
m Keys k
ks
where
m :: Map k a
m = forall k a b. Ord k => Map k a -> Map k b -> Map k a
Data.Map.difference Map k a
mL Map k b
mR
ks :: Keys k
ks = forall a. (a -> Bool) -> Keys a -> Keys a
filterKeys (\k
k -> forall k a. Ord k => k -> Map k a -> Bool
Data.Map.notMember k
k Map k b
mR) Keys k
ksL
{-# INLINABLE difference #-}
foldMapWithKey :: (Monoid m, Ord k) => (k -> a -> m) -> Map k a -> m
foldMapWithKey :: forall m k a. (Monoid m, Ord k) => (k -> a -> m) -> Map k a -> m
foldMapWithKey k -> a -> m
f (Map Map k a
m Keys k
Sorted) = forall m k a. Monoid m => (k -> a -> m) -> Map k a -> m
Data.Map.foldMapWithKey k -> a -> m
f Map k a
m
foldMapWithKey k -> a -> m
f Map k a
m = forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry k -> a -> m
f) (forall k v. Ord k => Map k v -> [(k, v)]
toList Map k a
m)
{-# INLINABLE foldMapWithKey #-}
mapWithKey :: (k -> a -> b) -> Map k a -> Map k b
mapWithKey :: forall k a b. (k -> a -> b) -> Map k a -> Map k b
mapWithKey k -> a -> b
f (Map Map k a
m Keys k
ks) = forall k v. Map k v -> Keys k -> Map k v
Map Map k b
m' Keys k
ks
where
m' :: Map k b
m' = forall k a b. (k -> a -> b) -> Map k a -> Map k b
Data.Map.mapWithKey k -> a -> b
f Map k a
m
{-# INLINABLE mapWithKey #-}
traverseWithKey
:: Ord k => Applicative f => (k -> a -> f b) -> Map k a -> f (Map k b)
traverseWithKey :: forall k (f :: * -> *) a b.
(Ord k, Applicative f) =>
(k -> a -> f b) -> Map k a -> f (Map k b)
traverseWithKey k -> a -> f b
f (Map Map k a
m Keys k
Sorted) =
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Map k b
m' -> forall k v. Map k v -> Keys k -> Map k v
Map Map k b
m' forall a. Keys a
Sorted) (forall (t :: * -> *) k a b.
Applicative t =>
(k -> a -> t b) -> Map k a -> t (Map k b)
Data.Map.traverseWithKey k -> a -> f b
f Map k a
m)
traverseWithKey k -> a -> f b
f Map k a
m =
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall k v. Ord k => [(k, v)] -> Map k v
fromList (forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (k, a) -> f (k, b)
f' (forall k v. Ord k => Map k v -> [(k, v)]
toList Map k a
m))
where
f' :: (k, a) -> f (k, b)
f' (k
k, a
a) = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((,) k
k) (k -> a -> f b
f k
k a
a)
{-# INLINABLE traverseWithKey #-}
unorderedTraverseWithKey
:: Ord k => Applicative f => (k -> a -> f b) -> Map k a -> f (Map k b)
unorderedTraverseWithKey :: forall k (f :: * -> *) a b.
(Ord k, Applicative f) =>
(k -> a -> f b) -> Map k a -> f (Map k b)
unorderedTraverseWithKey k -> a -> f b
f (Map Map k a
m Keys k
ks) =
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Map k b
m' -> forall k v. Map k v -> Keys k -> Map k v
Map Map k b
m' Keys k
ks) (forall (t :: * -> *) k a b.
Applicative t =>
(k -> a -> t b) -> Map k a -> t (Map k b)
Data.Map.traverseWithKey k -> a -> f b
f Map k a
m)
{-# INLINABLE unorderedTraverseWithKey #-}
unorderedTraverseWithKey_
:: Ord k => Applicative f => (k -> a -> f ()) -> Map k a -> f ()
unorderedTraverseWithKey_ :: forall k (f :: * -> *) a.
(Ord k, Applicative f) =>
(k -> a -> f ()) -> Map k a -> f ()
unorderedTraverseWithKey_ k -> a -> f ()
f (Map Map k a
m Keys k
_) =
forall a k b. (a -> k -> b -> a) -> a -> Map k b -> a
Data.Map.foldlWithKey' (\f ()
acc k
k a
v -> f ()
acc forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> k -> a -> f ()
f k
k a
v) (forall (f :: * -> *) a. Applicative f => a -> f a
pure ()) Map k a
m
{-# INLINABLE unorderedTraverseWithKey_ #-}
toList :: Ord k => Map k v -> [(k, v)]
toList :: forall k v. Ord k => Map k v -> [(k, v)]
toList (Map Map k v
m Keys k
Sorted) = forall k a. Map k a -> [(k, a)]
Data.Map.toList Map k v
m
toList (Map Map k v
m (Original [k]
ks)) = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\k
k -> (k
k, Map k v
m forall k a. Ord k => Map k a -> k -> a
Data.Map.! k
k)) [k]
ks
{-# INLINABLE toList #-}
toAscList :: Map k v -> [(k, v)]
toAscList :: forall k v. Map k v -> [(k, v)]
toAscList (Map Map k v
m Keys k
_) = forall k a. Map k a -> [(k, a)]
Data.Map.toAscList Map k v
m
{-# INLINABLE toAscList #-}
toMap :: Map k v -> Data.Map.Map k v
toMap :: forall k v. Map k v -> Map k v
toMap (Map Map k v
m Keys k
_) = Map k v
m
{-# INLINABLE toMap #-}
keys :: Map k v -> [k]
keys :: forall k v. Map k v -> [k]
keys (Map Map k v
m Keys k
Sorted) = forall k a. Map k a -> [k]
Data.Map.keys Map k v
m
keys (Map Map k v
_ (Original [k]
ks)) = [k]
ks
{-# INLINABLE keys #-}
elems :: Ord k => Map k v -> [v]
elems :: forall k v. Ord k => Map k v -> [v]
elems (Map Map k v
m Keys k
Sorted) = forall k a. Map k a -> [a]
Data.Map.elems Map k v
m
elems (Map Map k v
m (Original [k]
ks)) = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\k
k -> Map k v
m forall k a. Ord k => Map k a -> k -> a
Data.Map.! k
k) [k]
ks
{-# INLINABLE elems #-}
keysSet :: Map k v -> Data.Set.Set k
keysSet :: forall k v. Map k v -> Set k
keysSet (Map Map k v
m Keys k
_) = forall k a. Map k a -> Set k
Data.Map.keysSet Map k v
m
{-# INLINABLE keysSet #-}
filterKeys :: (a -> Bool) -> Keys a -> Keys a
filterKeys :: forall a. (a -> Bool) -> Keys a -> Keys a
filterKeys a -> Bool
_ Keys a
Sorted = forall a. Keys a
Sorted
filterKeys a -> Bool
f (Original [a]
ks) = forall a. [a] -> Keys a
Original (forall a. (a -> Bool) -> [a] -> [a]
Prelude.filter a -> Bool
f [a]
ks)
{-# INLINABLE filterKeys #-}
partitionKeys :: (a -> Bool) -> Keys a -> (Keys a, Keys a)
partitionKeys :: forall a. (a -> Bool) -> Keys a -> (Keys a, Keys a)
partitionKeys a -> Bool
_ Keys a
Sorted = (forall a. Keys a
Sorted, forall a. Keys a
Sorted)
partitionKeys a -> Bool
f (Original [a]
ks) =
let ([a]
kpass, [a]
kfail) = forall a. (a -> Bool) -> [a] -> ([a], [a])
Data.List.partition a -> Bool
f [a]
ks
in (forall a. [a] -> Keys a
Original [a]
kpass, forall a. [a] -> Keys a
Original [a]
kfail)
{-# INLINABLE partitionKeys #-}