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 m =
let
(x, _) = split k m
in
x
above :: Ord k => k -> Map k a -> Map k a
above k m =
let
(_, x) = split k m
in
x
belowInclusive :: Ord k => k -> Map k a -> Map k a
belowInclusive k m =
let
(x, at, _) = splitLookup k m
in
case at of
Nothing -> x
Just v -> insert k v x
aboveInclusive :: Ord k => k -> Map k a -> Map k a
aboveInclusive k m =
let
(_, at, x) = splitLookup k m
in
case at of
Nothing -> x
Just v -> insert k v x