module Data.Map.Merge.Set.Lazy
(
M.SimpleWhenMissing
, Internal.SimpleWhenMissingSet
, Internal.SimpleWhenMatched
, Internal.merge
, Internal.dropMatched
, Internal.filterMatched
, mapMatched
, mapMaybeMatched
, M.dropMissing
, M.preserveMissing
, M.mapMissing
, M.filterMissing
, M.mapMaybeMissing
, Internal.dropMissingSet
, generateMissingSet
, generateMaybeMissingSet
, M.WhenMissing
, Internal.WhenMissingSet
, Internal.WhenMatched
, Internal.mergeA
, Internal.filterAMatched
, traverseMatched
, traverseMaybeMatched
, M.filterAMissing
, M.traverseMissing
, M.traverseMaybeMissing
, M.whenMissing
, generateAMissingSet
, generateMaybeAMissingSet
, Internal.runWhenMatched
, Internal.runWhenMissingSet
) where
import qualified Data.Map.Internal as M
import qualified Data.Map.Merge.Set.Internal as Internal
import Data.Map.Merge.Set.Internal (WhenMatched(..), WhenMissingSet(..))
mapMatched :: Applicative f => (k -> a -> b) -> WhenMatched f k a b
mapMatched :: forall (f :: * -> *) k a b.
Applicative f =>
(k -> a -> b) -> WhenMatched f k a b
mapMatched k -> a -> b
f = (k -> a -> f (Maybe b)) -> WhenMatched f k a b
forall (f :: * -> *) k a b.
(k -> a -> f (Maybe b)) -> WhenMatched f k a b
WhenMatched (\k
k a
x -> Maybe b -> f (Maybe b)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (b -> Maybe b
forall a. a -> Maybe a
Just (k -> a -> b
f k
k a
x)))
{-# INLINE mapMatched #-}
mapMaybeMatched :: Applicative f => (k -> a -> Maybe b) -> WhenMatched f k a b
mapMaybeMatched :: forall (f :: * -> *) k a b.
Applicative f =>
(k -> a -> Maybe b) -> WhenMatched f k a b
mapMaybeMatched k -> a -> Maybe b
f = (k -> a -> f (Maybe b)) -> WhenMatched f k a b
forall (f :: * -> *) k a b.
(k -> a -> f (Maybe b)) -> WhenMatched f k a b
WhenMatched (\k
k a
x -> Maybe b -> f (Maybe b)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (k -> a -> Maybe b
f k
k a
x))
{-# INLINE mapMaybeMatched #-}
traverseMatched :: Functor f => (k -> a -> f b) -> WhenMatched f k a b
traverseMatched :: forall (f :: * -> *) k a b.
Functor f =>
(k -> a -> f b) -> WhenMatched f k a b
traverseMatched k -> a -> f b
f = (k -> a -> f (Maybe b)) -> WhenMatched f k a b
forall (f :: * -> *) k a b.
(k -> a -> f (Maybe b)) -> WhenMatched f k a b
WhenMatched (\k
k a
x -> b -> Maybe b
forall a. a -> Maybe a
Just (b -> Maybe b) -> f b -> f (Maybe b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> k -> a -> f b
f k
k a
x)
{-# INLINE traverseMatched #-}
traverseMaybeMatched :: (k -> a -> f (Maybe b)) -> WhenMatched f k a b
traverseMaybeMatched :: forall k a (f :: * -> *) b.
(k -> a -> f (Maybe b)) -> WhenMatched f k a b
traverseMaybeMatched = (k -> a -> f (Maybe b)) -> WhenMatched f k a b
forall (f :: * -> *) k a b.
(k -> a -> f (Maybe b)) -> WhenMatched f k a b
WhenMatched
generateMissingSet :: Applicative f => (k -> a) -> WhenMissingSet f k a
generateMissingSet :: forall (f :: * -> *) k a.
Applicative f =>
(k -> a) -> WhenMissingSet f k a
generateMissingSet k -> a
f = WhenMissingSet
{ missingSubtree :: Set k -> f (Map k a)
missingSubtree = \Set k
s -> Map k a -> f (Map k a)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((k -> a) -> Set k -> Map k a
forall k a. (k -> a) -> Set k -> Map k a
M.fromSet k -> a
f Set k
s)
, missingKey :: k -> f (Maybe a)
missingKey = \k
k -> Maybe a -> f (Maybe a)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> Maybe a
forall a. a -> Maybe a
Just (k -> a
f k
k))
}
{-# INLINE generateMissingSet #-}
generateAMissingSet :: Applicative f => (k -> f a) -> WhenMissingSet f k a
generateAMissingSet :: forall (f :: * -> *) k a.
Applicative f =>
(k -> f a) -> WhenMissingSet f k a
generateAMissingSet k -> f a
f = WhenMissingSet
{ missingSubtree :: Set k -> f (Map k a)
missingSubtree = (k -> f a) -> Set k -> f (Map k a)
forall (f :: * -> *) k a.
Applicative f =>
(k -> f a) -> Set k -> f (Map k a)
M.fromSetA k -> f a
f
, missingKey :: k -> f (Maybe a)
missingKey = \k
k -> a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> f a -> f (Maybe a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> k -> f a
f k
k
}
{-# INLINE generateAMissingSet #-}
generateMaybeMissingSet
:: Applicative f => (k -> Maybe a) -> WhenMissingSet f k a
generateMaybeMissingSet :: forall (f :: * -> *) k a.
Applicative f =>
(k -> Maybe a) -> WhenMissingSet f k a
generateMaybeMissingSet k -> Maybe a
f = WhenMissingSet
{ missingSubtree :: Set k -> f (Map k a)
missingSubtree = \Set k
s -> Map k a -> f (Map k a)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((k -> Maybe a) -> Set k -> Map k a
forall k a. (k -> Maybe a) -> Set k -> Map k a
M.fromSetMaybe k -> Maybe a
f Set k
s)
, missingKey :: k -> f (Maybe a)
missingKey = \k
k -> Maybe a -> f (Maybe a)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (k -> Maybe a
f k
k)
}
{-# INLINE generateMaybeMissingSet #-}
generateMaybeAMissingSet
:: Applicative f => (k -> f (Maybe a)) -> WhenMissingSet f k a
generateMaybeAMissingSet :: forall (f :: * -> *) k a.
Applicative f =>
(k -> f (Maybe a)) -> WhenMissingSet f k a
generateMaybeAMissingSet k -> f (Maybe a)
f = WhenMissingSet
{ missingSubtree :: Set k -> f (Map k a)
missingSubtree = (k -> f (Maybe a)) -> Set k -> f (Map k a)
forall (f :: * -> *) k a.
Applicative f =>
(k -> f (Maybe a)) -> Set k -> f (Map k a)
M.fromSetMaybeA k -> f (Maybe a)
f
, missingKey :: k -> f (Maybe a)
missingKey = k -> f (Maybe a)
f
}
{-# INLINE generateMaybeAMissingSet #-}