{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

-----------------------------------------------------------------------------
-- |
-- Module      :  Language.Haskell.TH.Desugar.OMap
-- Copyright   :  (C) 2016-2018 Daniel Wagner, 2019 Ryan Scott
-- License     :  BSD-style (see LICENSE)
-- Maintainer  :  Ryan Scott
-- Stability   :  experimental
-- Portability :  non-portable
--
-- An 'OMap' behaves much like a 'M.Map', with all the same asymptotics, but
-- also remembers the order that keys were inserted.
--
-- This module offers a simplified version of the "Data.Map.Ordered" API
-- that assumes left-biased indices everywhere and uses a different 'Semigroup'
-- instance (the one in this module uses @('<>') = 'union'@) and 'Monoid'
-- instance (the one in this module uses @'mappend' = 'union'@).
--
----------------------------------------------------------------------------
module Language.Haskell.TH.Desugar.OMap
    ( OMap(..)
    -- * Trivial maps
    , empty, singleton
    -- * Insertion
    , insertPre, insertPost, union, unionWithKey
    -- * Deletion
    , delete, filterWithKey, (\\), intersection, intersectionWithKey
    -- * Query
    , null, size, member, notMember, lookup
    -- * Indexing
    , Index, lookupIndex, lookupAt
    -- * List conversions
    , fromList, assocs, toAscList
    -- * 'M.Map' conversion
    , toMap
    ) where

import Data.Coerce
import Data.Data
import qualified Data.Map.Lazy as M (Map)
import Data.Map.Ordered (Bias(..), Index, L)
import qualified Data.Map.Ordered as OM
import Prelude hiding (filter, lookup, null)

#if !(MIN_VERSION_base(4,8,0))
import Data.Foldable (Foldable)
import Data.Monoid (Monoid(..))
import Data.Traversable (Traversable)
#endif

#if !(MIN_VERSION_base(4,11,0))
import Data.Semigroup (Semigroup(..))
#endif

#if __GLASGOW_HASKELL__ < 710
deriving instance Typeable L
#endif

-- | An ordered map whose 'insertPre', 'insertPost', 'intersection',
-- 'intersectionWithKey', 'union', and 'unionWithKey' operations are biased
-- towards leftmost indices when when breaking ties between keys.
newtype OMap k v = OMap (Bias L (OM.OMap k v))
  deriving (Typeable (OMap k v)
DataType
Constr
Typeable (OMap k v)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> OMap k v -> c (OMap k v))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (OMap k v))
-> (OMap k v -> Constr)
-> (OMap k v -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (OMap k v)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (OMap k v)))
-> ((forall b. Data b => b -> b) -> OMap k v -> OMap k v)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> OMap k v -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> OMap k v -> r)
-> (forall u. (forall d. Data d => d -> u) -> OMap k v -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> OMap k v -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v))
-> Data (OMap k v)
OMap k v -> DataType
OMap k v -> Constr
(forall b. Data b => b -> b) -> OMap k v -> OMap k v
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> OMap k v -> c (OMap k v)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (OMap k v)
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (OMap k v))
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 u. Int -> (forall d. Data d => d -> u) -> OMap k v -> u
forall u. (forall d. Data d => d -> u) -> OMap k v -> [u]
forall k v. (Data k, Data v, Ord k) => Typeable (OMap k v)
forall k v. (Data k, Data v, Ord k) => OMap k v -> DataType
forall k v. (Data k, Data v, Ord k) => OMap k v -> Constr
forall k v.
(Data k, Data v, Ord k) =>
(forall b. Data b => b -> b) -> OMap k v -> OMap k v
forall k v u.
(Data k, Data v, Ord k) =>
Int -> (forall d. Data d => d -> u) -> OMap k v -> u
forall k v u.
(Data k, Data v, Ord k) =>
(forall d. Data d => d -> u) -> OMap k v -> [u]
forall k v r r'.
(Data k, Data v, Ord k) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> OMap k v -> r
forall k v r r'.
(Data k, Data v, Ord k) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> OMap k v -> r
forall k v (m :: * -> *).
(Data k, Data v, Ord k, Monad m) =>
(forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v)
forall k v (m :: * -> *).
(Data k, Data v, Ord k, MonadPlus m) =>
(forall d. Data d => d -> m d) -> OMap k v -> m (OMap 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 (OMap 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) -> OMap k v -> c (OMap k v)
forall k v (t :: * -> *) (c :: * -> *).
(Data k, Data v, Ord k, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (OMap 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 (OMap k v))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> OMap k v -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> OMap k v -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (OMap k v)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> OMap k v -> c (OMap k v)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (OMap k v))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (OMap k v))
$cOMap :: Constr
$tOMap :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v)
$cgmapMo :: forall k v (m :: * -> *).
(Data k, Data v, Ord k, MonadPlus m) =>
(forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v)
gmapMp :: (forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v)
$cgmapMp :: forall k v (m :: * -> *).
(Data k, Data v, Ord k, MonadPlus m) =>
(forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v)
gmapM :: (forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v)
$cgmapM :: forall k v (m :: * -> *).
(Data k, Data v, Ord k, Monad m) =>
(forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v)
gmapQi :: Int -> (forall d. Data d => d -> u) -> OMap k v -> u
$cgmapQi :: forall k v u.
(Data k, Data v, Ord k) =>
Int -> (forall d. Data d => d -> u) -> OMap k v -> u
gmapQ :: (forall d. Data d => d -> u) -> OMap k v -> [u]
$cgmapQ :: forall k v u.
(Data k, Data v, Ord k) =>
(forall d. Data d => d -> u) -> OMap k v -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> OMap 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') -> OMap k v -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> OMap 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') -> OMap k v -> r
gmapT :: (forall b. Data b => b -> b) -> OMap k v -> OMap k v
$cgmapT :: forall k v.
(Data k, Data v, Ord k) =>
(forall b. Data b => b -> b) -> OMap k v -> OMap k v
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (OMap 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 (OMap k v))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (OMap 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 (OMap k v))
dataTypeOf :: OMap k v -> DataType
$cdataTypeOf :: forall k v. (Data k, Data v, Ord k) => OMap k v -> DataType
toConstr :: OMap k v -> Constr
$ctoConstr :: forall k v. (Data k, Data v, Ord k) => OMap k v -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (OMap 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 (OMap k v)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> OMap k v -> c (OMap 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) -> OMap k v -> c (OMap k v)
$cp1Data :: forall k v. (Data k, Data v, Ord k) => Typeable (OMap k v)
Data, OMap k a -> Bool
(a -> m) -> OMap k a -> m
(a -> b -> b) -> b -> OMap k a -> b
(forall m. Monoid m => OMap k m -> m)
-> (forall m a. Monoid m => (a -> m) -> OMap k a -> m)
-> (forall m a. Monoid m => (a -> m) -> OMap k a -> m)
-> (forall a b. (a -> b -> b) -> b -> OMap k a -> b)
-> (forall a b. (a -> b -> b) -> b -> OMap k a -> b)
-> (forall b a. (b -> a -> b) -> b -> OMap k a -> b)
-> (forall b a. (b -> a -> b) -> b -> OMap k a -> b)
-> (forall a. (a -> a -> a) -> OMap k a -> a)
-> (forall a. (a -> a -> a) -> OMap k a -> a)
-> (forall a. OMap k a -> [a])
-> (forall a. OMap k a -> Bool)
-> (forall a. OMap k a -> Int)
-> (forall a. Eq a => a -> OMap k a -> Bool)
-> (forall a. Ord a => OMap k a -> a)
-> (forall a. Ord a => OMap k a -> a)
-> (forall a. Num a => OMap k a -> a)
-> (forall a. Num a => OMap k a -> a)
-> Foldable (OMap k)
forall a. Eq a => a -> OMap k a -> Bool
forall a. Num a => OMap k a -> a
forall a. Ord a => OMap k a -> a
forall m. Monoid m => OMap k m -> m
forall a. OMap k a -> Bool
forall a. OMap k a -> Int
forall a. OMap k a -> [a]
forall a. (a -> a -> a) -> OMap k a -> a
forall k a. Eq a => a -> OMap k a -> Bool
forall k a. Num a => OMap k a -> a
forall k a. Ord a => OMap k a -> a
forall m a. Monoid m => (a -> m) -> OMap k a -> m
forall k m. Monoid m => OMap k m -> m
forall k a. OMap k a -> Bool
forall k a. OMap k a -> Int
forall k a. OMap k a -> [a]
forall b a. (b -> a -> b) -> b -> OMap k a -> b
forall a b. (a -> b -> b) -> b -> OMap k a -> b
forall k a. (a -> a -> a) -> OMap k a -> a
forall k m a. Monoid m => (a -> m) -> OMap k a -> m
forall k b a. (b -> a -> b) -> b -> OMap k a -> b
forall k a b. (a -> b -> b) -> b -> OMap k a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: OMap k a -> a
$cproduct :: forall k a. Num a => OMap k a -> a
sum :: OMap k a -> a
$csum :: forall k a. Num a => OMap k a -> a
minimum :: OMap k a -> a
$cminimum :: forall k a. Ord a => OMap k a -> a
maximum :: OMap k a -> a
$cmaximum :: forall k a. Ord a => OMap k a -> a
elem :: a -> OMap k a -> Bool
$celem :: forall k a. Eq a => a -> OMap k a -> Bool
length :: OMap k a -> Int
$clength :: forall k a. OMap k a -> Int
null :: OMap k a -> Bool
$cnull :: forall k a. OMap k a -> Bool
toList :: OMap k a -> [a]
$ctoList :: forall k a. OMap k a -> [a]
foldl1 :: (a -> a -> a) -> OMap k a -> a
$cfoldl1 :: forall k a. (a -> a -> a) -> OMap k a -> a
foldr1 :: (a -> a -> a) -> OMap k a -> a
$cfoldr1 :: forall k a. (a -> a -> a) -> OMap k a -> a
foldl' :: (b -> a -> b) -> b -> OMap k a -> b
$cfoldl' :: forall k b a. (b -> a -> b) -> b -> OMap k a -> b
foldl :: (b -> a -> b) -> b -> OMap k a -> b
$cfoldl :: forall k b a. (b -> a -> b) -> b -> OMap k a -> b
foldr' :: (a -> b -> b) -> b -> OMap k a -> b
$cfoldr' :: forall k a b. (a -> b -> b) -> b -> OMap k a -> b
foldr :: (a -> b -> b) -> b -> OMap k a -> b
$cfoldr :: forall k a b. (a -> b -> b) -> b -> OMap k a -> b
foldMap' :: (a -> m) -> OMap k a -> m
$cfoldMap' :: forall k m a. Monoid m => (a -> m) -> OMap k a -> m
foldMap :: (a -> m) -> OMap k a -> m
$cfoldMap :: forall k m a. Monoid m => (a -> m) -> OMap k a -> m
fold :: OMap k m -> m
$cfold :: forall k m. Monoid m => OMap k m -> m
Foldable, a -> OMap k b -> OMap k a
(a -> b) -> OMap k a -> OMap k b
(forall a b. (a -> b) -> OMap k a -> OMap k b)
-> (forall a b. a -> OMap k b -> OMap k a) -> Functor (OMap k)
forall a b. a -> OMap k b -> OMap k a
forall a b. (a -> b) -> OMap k a -> OMap k b
forall k a b. a -> OMap k b -> OMap k a
forall k a b. (a -> b) -> OMap k a -> OMap k b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> OMap k b -> OMap k a
$c<$ :: forall k a b. a -> OMap k b -> OMap k a
fmap :: (a -> b) -> OMap k a -> OMap k b
$cfmap :: forall k a b. (a -> b) -> OMap k a -> OMap k b
Functor, OMap k v -> OMap k v -> Bool
(OMap k v -> OMap k v -> Bool)
-> (OMap k v -> OMap k v -> Bool) -> Eq (OMap k v)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k v. (Eq k, Eq v) => OMap k v -> OMap k v -> Bool
/= :: OMap k v -> OMap k v -> Bool
$c/= :: forall k v. (Eq k, Eq v) => OMap k v -> OMap k v -> Bool
== :: OMap k v -> OMap k v -> Bool
$c== :: forall k v. (Eq k, Eq v) => OMap k v -> OMap k v -> Bool
Eq, Eq (OMap k v)
Eq (OMap k v)
-> (OMap k v -> OMap k v -> Ordering)
-> (OMap k v -> OMap k v -> Bool)
-> (OMap k v -> OMap k v -> Bool)
-> (OMap k v -> OMap k v -> Bool)
-> (OMap k v -> OMap k v -> Bool)
-> (OMap k v -> OMap k v -> OMap k v)
-> (OMap k v -> OMap k v -> OMap k v)
-> Ord (OMap k v)
OMap k v -> OMap k v -> Bool
OMap k v -> OMap k v -> Ordering
OMap k v -> OMap k v -> OMap k v
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall k v. (Ord k, Ord v) => Eq (OMap k v)
forall k v. (Ord k, Ord v) => OMap k v -> OMap k v -> Bool
forall k v. (Ord k, Ord v) => OMap k v -> OMap k v -> Ordering
forall k v. (Ord k, Ord v) => OMap k v -> OMap k v -> OMap k v
min :: OMap k v -> OMap k v -> OMap k v
$cmin :: forall k v. (Ord k, Ord v) => OMap k v -> OMap k v -> OMap k v
max :: OMap k v -> OMap k v -> OMap k v
$cmax :: forall k v. (Ord k, Ord v) => OMap k v -> OMap k v -> OMap k v
>= :: OMap k v -> OMap k v -> Bool
$c>= :: forall k v. (Ord k, Ord v) => OMap k v -> OMap k v -> Bool
> :: OMap k v -> OMap k v -> Bool
$c> :: forall k v. (Ord k, Ord v) => OMap k v -> OMap k v -> Bool
<= :: OMap k v -> OMap k v -> Bool
$c<= :: forall k v. (Ord k, Ord v) => OMap k v -> OMap k v -> Bool
< :: OMap k v -> OMap k v -> Bool
$c< :: forall k v. (Ord k, Ord v) => OMap k v -> OMap k v -> Bool
compare :: OMap k v -> OMap k v -> Ordering
$ccompare :: forall k v. (Ord k, Ord v) => OMap k v -> OMap k v -> Ordering
$cp1Ord :: forall k v. (Ord k, Ord v) => Eq (OMap k v)
Ord, ReadPrec [OMap k v]
ReadPrec (OMap k v)
Int -> ReadS (OMap k v)
ReadS [OMap k v]
(Int -> ReadS (OMap k v))
-> ReadS [OMap k v]
-> ReadPrec (OMap k v)
-> ReadPrec [OMap k v]
-> Read (OMap k v)
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall k v. (Ord k, Read k, Read v) => ReadPrec [OMap k v]
forall k v. (Ord k, Read k, Read v) => ReadPrec (OMap k v)
forall k v. (Ord k, Read k, Read v) => Int -> ReadS (OMap k v)
forall k v. (Ord k, Read k, Read v) => ReadS [OMap k v]
readListPrec :: ReadPrec [OMap k v]
$creadListPrec :: forall k v. (Ord k, Read k, Read v) => ReadPrec [OMap k v]
readPrec :: ReadPrec (OMap k v)
$creadPrec :: forall k v. (Ord k, Read k, Read v) => ReadPrec (OMap k v)
readList :: ReadS [OMap k v]
$creadList :: forall k v. (Ord k, Read k, Read v) => ReadS [OMap k v]
readsPrec :: Int -> ReadS (OMap k v)
$creadsPrec :: forall k v. (Ord k, Read k, Read v) => Int -> ReadS (OMap k v)
Read, Int -> OMap k v -> ShowS
[OMap k v] -> ShowS
OMap k v -> String
(Int -> OMap k v -> ShowS)
-> (OMap k v -> String) -> ([OMap k v] -> ShowS) -> Show (OMap k v)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k v. (Show k, Show v) => Int -> OMap k v -> ShowS
forall k v. (Show k, Show v) => [OMap k v] -> ShowS
forall k v. (Show k, Show v) => OMap k v -> String
showList :: [OMap k v] -> ShowS
$cshowList :: forall k v. (Show k, Show v) => [OMap k v] -> ShowS
show :: OMap k v -> String
$cshow :: forall k v. (Show k, Show v) => OMap k v -> String
showsPrec :: Int -> OMap k v -> ShowS
$cshowsPrec :: forall k v. (Show k, Show v) => Int -> OMap k v -> ShowS
Show, Functor (OMap k)
Foldable (OMap k)
Functor (OMap k)
-> Foldable (OMap k)
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> OMap k a -> f (OMap k b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    OMap k (f a) -> f (OMap k a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> OMap k a -> m (OMap k b))
-> (forall (m :: * -> *) a.
    Monad m =>
    OMap k (m a) -> m (OMap k a))
-> Traversable (OMap k)
(a -> f b) -> OMap k a -> f (OMap k b)
forall k. Ord k => Functor (OMap k)
forall k. Ord k => Foldable (OMap k)
forall k (m :: * -> *) a.
(Ord k, Monad m) =>
OMap k (m a) -> m (OMap k a)
forall k (f :: * -> *) a.
(Ord k, Applicative f) =>
OMap k (f a) -> f (OMap k a)
forall k (m :: * -> *) a b.
(Ord k, Monad m) =>
(a -> m b) -> OMap k a -> m (OMap k b)
forall k (f :: * -> *) a b.
(Ord k, Applicative f) =>
(a -> f b) -> OMap k a -> f (OMap k b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => OMap k (m a) -> m (OMap k a)
forall (f :: * -> *) a.
Applicative f =>
OMap k (f a) -> f (OMap k a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> OMap k a -> m (OMap k b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> OMap k a -> f (OMap k b)
sequence :: OMap k (m a) -> m (OMap k a)
$csequence :: forall k (m :: * -> *) a.
(Ord k, Monad m) =>
OMap k (m a) -> m (OMap k a)
mapM :: (a -> m b) -> OMap k a -> m (OMap k b)
$cmapM :: forall k (m :: * -> *) a b.
(Ord k, Monad m) =>
(a -> m b) -> OMap k a -> m (OMap k b)
sequenceA :: OMap k (f a) -> f (OMap k a)
$csequenceA :: forall k (f :: * -> *) a.
(Ord k, Applicative f) =>
OMap k (f a) -> f (OMap k a)
traverse :: (a -> f b) -> OMap k a -> f (OMap k b)
$ctraverse :: forall k (f :: * -> *) a b.
(Ord k, Applicative f) =>
(a -> f b) -> OMap k a -> f (OMap k b)
$cp2Traversable :: forall k. Ord k => Foldable (OMap k)
$cp1Traversable :: forall k. Ord k => Functor (OMap k)
Traversable, Typeable)

instance Ord k => Semigroup (OMap k v) where
  <> :: OMap k v -> OMap k v -> OMap k v
(<>) = OMap k v -> OMap k v -> OMap k v
forall k v. Ord k => OMap k v -> OMap k v -> OMap k v
union
instance Ord k => Monoid (OMap k v) where
  mempty :: OMap k v
mempty = OMap k v
forall k v. OMap k v
empty
#if !(MIN_VERSION_base(4,11,0))
  mappend = (<>)
#endif

empty :: forall k v. OMap k v
empty :: OMap k v
empty = OMap k v -> OMap k v
coerce (OMap k v
forall k v. OMap k v
OM.empty :: OM.OMap k v)

singleton :: k -> v -> OMap k v
singleton :: k -> v -> OMap k v
singleton k
k v
v = OMap k v -> OMap k v
coerce ((k, v) -> OMap k v
forall k v. (k, v) -> OMap k v
OM.singleton (k
k, v
v))

-- | The value's index will be lower than the indices of the values in the
-- 'OSet'.
insertPre :: Ord k => k -> v -> OMap k v -> OMap k v
insertPre :: k -> v -> OMap k v -> OMap k v
insertPre k
k v
v = (OMap k v -> OMap k v) -> OMap k v -> OMap k v
coerce ((k
k, v
v) (k, v) -> OMap k v -> OMap k v
forall k v. Ord k => (k, v) -> OMap k v -> OMap k v
OM.|<)

-- | The value's index will be higher than the indices of the values in the
-- 'OSet'.
insertPost :: Ord k => OMap k v -> k -> v -> OMap k v
insertPost :: OMap k v -> k -> v -> OMap k v
insertPost OMap k v
m k
k v
v = OMap k v -> OMap k v
coerce (OMap k v -> OMap k v
coerce OMap k v
m OMap k v -> (k, v) -> OMap k v
forall k v. Ord k => OMap k v -> (k, v) -> OMap k v
OM.|> (k
k, v
v))

union :: forall k v. Ord k => OMap k v -> OMap k v -> OMap k v
union :: OMap k v -> OMap k v -> OMap k v
union = (OMap k v -> OMap k v -> OMap k v)
-> OMap k v -> OMap k v -> OMap k v
coerce (OMap k v -> OMap k v -> OMap k v
forall k v. Ord k => OMap k v -> OMap k v -> OMap k v
(OM.|<>) :: OM.OMap k v -> OM.OMap k v -> OM.OMap k v)

unionWithKey :: Ord k => (k -> v -> v -> v) -> OMap k v -> OMap k v -> OMap k v
unionWithKey :: (k -> v -> v -> v) -> OMap k v -> OMap k v -> OMap k v
unionWithKey k -> v -> v -> v
f = (OMap k v -> OMap k v -> OMap k v)
-> OMap k v -> OMap k v -> OMap k v
coerce ((k -> v -> v -> v) -> OMap k v -> OMap k v -> OMap k v
forall k v.
Ord k =>
(k -> v -> v -> v) -> OMap k v -> OMap k v -> OMap k v
OM.unionWithL k -> v -> v -> v
f)

delete :: forall k v. Ord k => k -> OMap k v -> OMap k v
delete :: k -> OMap k v -> OMap k v
delete = (k -> OMap k v -> OMap k v) -> k -> OMap k v -> OMap k v
coerce (k -> OMap k v -> OMap k v
forall k v. Ord k => k -> OMap k v -> OMap k v
OM.delete :: k -> OM.OMap k v -> OM.OMap k v)

filterWithKey :: Ord k => (k -> v -> Bool) -> OMap k v -> OMap k v
filterWithKey :: (k -> v -> Bool) -> OMap k v -> OMap k v
filterWithKey k -> v -> Bool
f = (OMap k v -> OMap k v) -> OMap k v -> OMap k v
coerce ((k -> v -> Bool) -> OMap k v -> OMap k v
forall k v. Ord k => (k -> v -> Bool) -> OMap k v -> OMap k v
OM.filter k -> v -> Bool
f)

(\\) :: forall k v v'. Ord k => OMap k v -> OMap k v' -> OMap k v
\\ :: OMap k v -> OMap k v' -> OMap k v
(\\) = (OMap k v -> OMap k v' -> OMap k v)
-> OMap k v -> OMap k v' -> OMap k v
coerce (OMap k v -> OMap k v' -> OMap k v
forall k v v'. Ord k => OMap k v -> OMap k v' -> OMap k v
(OM.\\) :: OM.OMap k v -> OM.OMap k v' -> OM.OMap k v)

intersection :: forall k v v'. Ord k => OMap k v -> OMap k v' -> OMap k v
intersection :: OMap k v -> OMap k v' -> OMap k v
intersection = (OMap k v -> OMap k v' -> OMap k v)
-> OMap k v -> OMap k v' -> OMap k v
coerce (OMap k v -> OMap k v' -> OMap k v
forall k v v'. Ord k => OMap k v -> OMap k v' -> OMap k v
(OM.|/\) :: OM.OMap k v -> OM.OMap k v' -> OM.OMap k v)

intersectionWithKey :: Ord k => (k -> v -> v' -> v'') -> OMap k v -> OMap k v' -> OMap k v''
intersectionWithKey :: (k -> v -> v' -> v'') -> OMap k v -> OMap k v' -> OMap k v''
intersectionWithKey k -> v -> v' -> v''
f = (OMap k v -> OMap k v' -> OMap k v'')
-> OMap k v -> OMap k v' -> OMap k v''
coerce ((k -> v -> v' -> v'') -> OMap k v -> OMap k v' -> OMap k v''
forall k v v' v''.
Ord k =>
(k -> v -> v' -> v'') -> OMap k v -> OMap k v' -> OMap k v''
OM.intersectionWith k -> v -> v' -> v''
f)

null :: forall k v. OMap k v -> Bool
null :: OMap k v -> Bool
null = (OMap k v -> Bool) -> OMap k v -> Bool
coerce (OMap k v -> Bool
forall k v. OMap k v -> Bool
OM.null :: OM.OMap k v -> Bool)

size :: forall k v. OMap k v -> Int
size :: OMap k v -> Int
size = (OMap k v -> Int) -> OMap k v -> Int
coerce (OMap k v -> Int
forall k v. OMap k v -> Int
OM.size :: OM.OMap k v -> Int)

member :: forall k v. Ord k => k -> OMap k v -> Bool
member :: k -> OMap k v -> Bool
member = (k -> OMap k v -> Bool) -> k -> OMap k v -> Bool
coerce (k -> OMap k v -> Bool
forall k v. Ord k => k -> OMap k v -> Bool
OM.member :: k -> OM.OMap k v -> Bool)

notMember :: forall k v. Ord k => k -> OMap k v -> Bool
notMember :: k -> OMap k v -> Bool
notMember = (k -> OMap k v -> Bool) -> k -> OMap k v -> Bool
coerce (k -> OMap k v -> Bool
forall k v. Ord k => k -> OMap k v -> Bool
OM.notMember :: k -> OM.OMap k v -> Bool)

lookup :: forall k v. Ord k => k -> OMap k v -> Maybe v
lookup :: k -> OMap k v -> Maybe v
lookup = (k -> OMap k v -> Maybe v) -> k -> OMap k v -> Maybe v
coerce (k -> OMap k v -> Maybe v
forall k v. Ord k => k -> OMap k v -> Maybe v
OM.lookup :: k -> OM.OMap k v -> Maybe v)

lookupIndex :: forall k v. Ord k => k -> OMap k v -> Maybe Index
lookupIndex :: k -> OMap k v -> Maybe Int
lookupIndex = (k -> OMap k v -> Maybe Int) -> k -> OMap k v -> Maybe Int
coerce (k -> OMap k v -> Maybe Int
forall k v. Ord k => k -> OMap k v -> Maybe Int
OM.findIndex :: k -> OM.OMap k v -> Maybe Index)

lookupAt :: forall k v. Index -> OMap k v -> Maybe (k, v)
lookupAt :: Int -> OMap k v -> Maybe (k, v)
lookupAt Int
i OMap k v
m = Maybe (k, v) -> Maybe (k, v)
coerce (OMap k v -> Int -> Maybe (k, v)
forall k v. OMap k v -> Int -> Maybe (k, v)
OM.elemAt (OMap k v -> OMap k v
coerce OMap k v
m) Int
i :: Maybe (k, v))

fromList :: Ord k => [(k, v)] -> OMap k v
fromList :: [(k, v)] -> OMap k v
fromList [(k, v)]
l = OMap k v -> OMap k v
coerce ([(k, v)] -> OMap k v
forall k v. Ord k => [(k, v)] -> OMap k v
OM.fromList [(k, v)]
l)

assocs :: forall k v. OMap k v -> [(k, v)]
assocs :: OMap k v -> [(k, v)]
assocs = (OMap k v -> [(k, v)]) -> OMap k v -> [(k, v)]
coerce (OMap k v -> [(k, v)]
forall k v. OMap k v -> [(k, v)]
OM.assocs :: OM.OMap k v -> [(k, v)])

toAscList :: forall k v. OMap k v -> [(k, v)]
toAscList :: OMap k v -> [(k, v)]
toAscList = (OMap k v -> [(k, v)]) -> OMap k v -> [(k, v)]
coerce (OMap k v -> [(k, v)]
forall k v. OMap k v -> [(k, v)]
OM.toAscList :: OM.OMap k v -> [(k, v)])

toMap :: forall k v. OMap k v -> M.Map k v
toMap :: OMap k v -> Map k v
toMap = (OMap k v -> Map k v) -> OMap k v -> Map k v
coerce (OMap k v -> Map k v
forall k v. OMap k v -> Map k v
OM.toMap :: OM.OMap k v -> M.Map k v)