module Data.Loc.Internal.Map
( module Data.Map
, below, above, belowInclusive, aboveInclusive
) where
import Data.Loc.Internal.Prelude
import Data.Map
below :: Ord k => k -> Map k a -> Map k a
below :: k -> Map k a -> Map k a
below k
k Map k a
m =
let
(Map k a
x, Map k a
_) = k -> Map k a -> (Map k a, Map k a)
forall k a. Ord k => k -> Map k a -> (Map k a, Map k a)
split k
k Map k a
m
in
Map k a
x
above :: Ord k => k -> Map k a -> Map k a
above :: k -> Map k a -> Map k a
above k
k Map k a
m =
let
(Map k a
_, Map k a
x) = k -> Map k a -> (Map k a, Map k a)
forall k a. Ord k => k -> Map k a -> (Map k a, Map k a)
split k
k Map k a
m
in
Map k a
x
belowInclusive :: Ord k => k -> Map k a -> Map k a
belowInclusive :: k -> Map k a -> Map k a
belowInclusive k
k Map k a
m =
let
(Map k a
x, Maybe a
at, Map k a
_) = k -> Map k a -> (Map k a, Maybe a, Map k a)
forall k a. Ord k => k -> Map k a -> (Map k a, Maybe a, Map k a)
splitLookup k
k Map k a
m
in
case Maybe a
at of
Maybe a
Nothing -> Map k a
x
Just a
v -> k -> a -> Map k a -> Map k a
forall k a. Ord k => k -> a -> Map k a -> Map k a
insert k
k a
v Map k a
x
aboveInclusive :: Ord k => k -> Map k a -> Map k a
aboveInclusive :: k -> Map k a -> Map k a
aboveInclusive k
k Map k a
m =
let
(Map k a
_, Maybe a
at, Map k a
x) = k -> Map k a -> (Map k a, Maybe a, Map k a)
forall k a. Ord k => k -> Map k a -> (Map k a, Maybe a, Map k a)
splitLookup k
k Map k a
m
in
case Maybe a
at of
Maybe a
Nothing -> Map k a
x
Just a
v -> k -> a -> Map k a -> Map k a
forall k a. Ord k => k -> a -> Map k a -> Map k a
insert k
k a
v Map k a
x