{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE TypeFamilies #-}
module Data.HashMap.Strict.InsOrd (
InsOrdHashMap,
empty,
singleton,
null,
size,
member,
lookup,
lookupDefault,
insert,
insertWith,
delete,
adjust,
update,
alter,
union,
unionWith,
unionWithKey,
unions,
map,
mapKeys,
traverseKeys,
mapWithKey,
traverseWithKey,
unorderedTraverse,
unorderedTraverseWithKey,
difference,
intersection,
intersectionWith,
intersectionWithKey,
foldl',
foldlWithKey',
foldr,
foldrWithKey,
foldMapWithKey,
unorderedFoldMap,
unorderedFoldMapWithKey,
filter,
filterWithKey,
mapMaybe,
mapMaybeWithKey,
keys,
elems,
toList,
toRevList,
fromList,
toHashMap,
fromHashMap,
hashMap,
unorderedTraversal,
valid,
) where
import Prelude hiding (filter, foldr, lookup, map, null)
import Control.Applicative (Const (..))
import Control.Arrow (first, second)
import Control.DeepSeq (NFData (..))
import Data.Aeson
import qualified Data.Aeson.Encoding as E
import Data.Data (Data, Typeable)
import qualified Data.Foldable as F
import Data.Foldable.WithIndex (FoldableWithIndex (..))
import Data.Functor.Apply (Apply (..))
import Data.Functor.Bind (Bind (..))
import Data.Functor.WithIndex (FunctorWithIndex (..))
import Data.Hashable (Hashable (..))
import Data.List (nub, sortBy)
import Data.Maybe (fromMaybe)
import Data.Ord (comparing)
import Data.Semigroup (Semigroup (..))
import Data.Traversable.WithIndex (TraversableWithIndex (..))
import Text.ParserCombinators.ReadPrec (prec)
import Text.Read
(Lexeme (..), Read (..), lexP, parens, readListPrecDefault)
import Control.Lens
(At (..), Index, Iso, IxValue, Ixed (..), Traversal, _1, _2, iso, (<&>))
import Control.Monad.Trans.State.Strict (State, runState, state)
import qualified Control.Lens as Lens
import qualified Optics.At as Optics
import qualified Optics.Core as Optics
import Data.HashMap.Strict (HashMap)
import qualified Data.HashMap.Strict as HashMap
import qualified GHC.Exts as Exts
#if MIN_VERSION_deepseq(1,4,3)
import qualified Control.DeepSeq as NF
#endif
import Data.HashMap.InsOrd.Internal
data P a = P !Int !a
deriving (a -> P b -> P a
(a -> b) -> P a -> P b
(forall a b. (a -> b) -> P a -> P b)
-> (forall a b. a -> P b -> P a) -> Functor P
forall a b. a -> P b -> P a
forall a b. (a -> b) -> P a -> P b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> P b -> P a
$c<$ :: forall a b. a -> P b -> P a
fmap :: (a -> b) -> P a -> P b
$cfmap :: forall a b. (a -> b) -> P a -> P b
Functor, P a -> Bool
(a -> m) -> P a -> m
(a -> b -> b) -> b -> P a -> b
(forall m. Monoid m => P m -> m)
-> (forall m a. Monoid m => (a -> m) -> P a -> m)
-> (forall m a. Monoid m => (a -> m) -> P a -> m)
-> (forall a b. (a -> b -> b) -> b -> P a -> b)
-> (forall a b. (a -> b -> b) -> b -> P a -> b)
-> (forall b a. (b -> a -> b) -> b -> P a -> b)
-> (forall b a. (b -> a -> b) -> b -> P a -> b)
-> (forall a. (a -> a -> a) -> P a -> a)
-> (forall a. (a -> a -> a) -> P a -> a)
-> (forall a. P a -> [a])
-> (forall a. P a -> Bool)
-> (forall a. P a -> Int)
-> (forall a. Eq a => a -> P a -> Bool)
-> (forall a. Ord a => P a -> a)
-> (forall a. Ord a => P a -> a)
-> (forall a. Num a => P a -> a)
-> (forall a. Num a => P a -> a)
-> Foldable P
forall a. Eq a => a -> P a -> Bool
forall a. Num a => P a -> a
forall a. Ord a => P a -> a
forall m. Monoid m => P m -> m
forall a. P a -> Bool
forall a. P a -> Int
forall a. P a -> [a]
forall a. (a -> a -> a) -> P a -> a
forall m a. Monoid m => (a -> m) -> P a -> m
forall b a. (b -> a -> b) -> b -> P a -> b
forall a b. (a -> b -> b) -> b -> P 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 :: P a -> a
$cproduct :: forall a. Num a => P a -> a
sum :: P a -> a
$csum :: forall a. Num a => P a -> a
minimum :: P a -> a
$cminimum :: forall a. Ord a => P a -> a
maximum :: P a -> a
$cmaximum :: forall a. Ord a => P a -> a
elem :: a -> P a -> Bool
$celem :: forall a. Eq a => a -> P a -> Bool
length :: P a -> Int
$clength :: forall a. P a -> Int
null :: P a -> Bool
$cnull :: forall a. P a -> Bool
toList :: P a -> [a]
$ctoList :: forall a. P a -> [a]
foldl1 :: (a -> a -> a) -> P a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> P a -> a
foldr1 :: (a -> a -> a) -> P a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> P a -> a
foldl' :: (b -> a -> b) -> b -> P a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> P a -> b
foldl :: (b -> a -> b) -> b -> P a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> P a -> b
foldr' :: (a -> b -> b) -> b -> P a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> P a -> b
foldr :: (a -> b -> b) -> b -> P a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> P a -> b
foldMap' :: (a -> m) -> P a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> P a -> m
foldMap :: (a -> m) -> P a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> P a -> m
fold :: P m -> m
$cfold :: forall m. Monoid m => P m -> m
Foldable, Functor P
Foldable P
Functor P
-> Foldable P
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> P a -> f (P b))
-> (forall (f :: * -> *) a. Applicative f => P (f a) -> f (P a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> P a -> m (P b))
-> (forall (m :: * -> *) a. Monad m => P (m a) -> m (P a))
-> Traversable P
(a -> f b) -> P a -> f (P 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 => P (m a) -> m (P a)
forall (f :: * -> *) a. Applicative f => P (f a) -> f (P a)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> P a -> m (P b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> P a -> f (P b)
sequence :: P (m a) -> m (P a)
$csequence :: forall (m :: * -> *) a. Monad m => P (m a) -> m (P a)
mapM :: (a -> m b) -> P a -> m (P b)
$cmapM :: forall (m :: * -> *) a b. Monad m => (a -> m b) -> P a -> m (P b)
sequenceA :: P (f a) -> f (P a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => P (f a) -> f (P a)
traverse :: (a -> f b) -> P a -> f (P b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> P a -> f (P b)
$cp2Traversable :: Foldable P
$cp1Traversable :: Functor P
Traversable, Typeable, Typeable (P a)
DataType
Constr
Typeable (P a)
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> P a -> c (P a))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (P a))
-> (P a -> Constr)
-> (P a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (P a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (P a)))
-> ((forall b. Data b => b -> b) -> P a -> P a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> P a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> P a -> r)
-> (forall u. (forall d. Data d => d -> u) -> P a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> P a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> P a -> m (P a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> P a -> m (P a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> P a -> m (P a))
-> Data (P a)
P a -> DataType
P a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (P a))
(forall b. Data b => b -> b) -> P a -> P a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> P a -> c (P a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (P a)
forall a. Data a => Typeable (P a)
forall a. Data a => P a -> DataType
forall a. Data a => P a -> Constr
forall a. Data a => (forall b. Data b => b -> b) -> P a -> P a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> P a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> P a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> P a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> P a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> P a -> m (P a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> P a -> m (P a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (P a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> P a -> c (P a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (P a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (P 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 u. Int -> (forall d. Data d => d -> u) -> P a -> u
forall u. (forall d. Data d => d -> u) -> P a -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> P a -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> P a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> P a -> m (P a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> P a -> m (P a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (P a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> P a -> c (P a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (P a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (P a))
$cP :: Constr
$tP :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> P a -> m (P a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> P a -> m (P a)
gmapMp :: (forall d. Data d => d -> m d) -> P a -> m (P a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> P a -> m (P a)
gmapM :: (forall d. Data d => d -> m d) -> P a -> m (P a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> P a -> m (P a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> P a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> P a -> u
gmapQ :: (forall d. Data d => d -> u) -> P a -> [u]
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> P a -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> P a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> P a -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> P a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> P a -> r
gmapT :: (forall b. Data b => b -> b) -> P a -> P a
$cgmapT :: forall a. Data a => (forall b. Data b => b -> b) -> P a -> P a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (P a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (P a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (P a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (P a))
dataTypeOf :: P a -> DataType
$cdataTypeOf :: forall a. Data a => P a -> DataType
toConstr :: P a -> Constr
$ctoConstr :: forall a. Data a => P a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (P a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (P a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> P a -> c (P a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> P a -> c (P a)
$cp1Data :: forall a. Data a => Typeable (P a)
Data)
instance NFData a => NFData (P a) where
rnf :: P a -> ()
rnf (P Int
_ a
a) = a -> ()
forall a. NFData a => a -> ()
rnf a
a
#if MIN_VERSION_deepseq(1,4,3)
instance NF.NFData1 P where
liftRnf :: (a -> ()) -> P a -> ()
liftRnf a -> ()
rnf1 (P Int
_ a
a) = a -> ()
rnf1 a
a
#endif
getPK :: P a -> Int
getPK :: P a -> Int
getPK (P Int
i a
_) = Int
i
{-# INLINABLE getPK #-}
getPV :: P a -> a
getPV :: P a -> a
getPV (P Int
_ a
a) = a
a
{-# INLINABLE getPV #-}
incPK :: Int -> P a -> P a
incPK :: Int -> P a -> P a
incPK Int
i (P Int
j a
x) = Int -> a -> P a
forall a. Int -> a -> P a
P (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
j) a
x
{-# INLINABLE incPK #-}
instance Eq a => Eq (P a) where
P Int
_ a
a == :: P a -> P a -> Bool
== P Int
_ a
b = a
a a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
b
instance Show a => Show (P a) where
showsPrec :: Int -> P a -> ShowS
showsPrec Int
d (P Int
_ a
x) = Int -> a -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
d a
x
instance Hashable a => Hashable (P a) where
hashWithSalt :: Int -> P a -> Int
hashWithSalt Int
salt (P Int
_ a
x) = Int -> a -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
salt a
x
data InsOrdHashMap k v = InsOrdHashMap
{ InsOrdHashMap k v -> Int
_getIndex :: !Int
, InsOrdHashMap k v -> HashMap k (P v)
getInsOrdHashMap :: !(HashMap k (P v))
}
deriving (a -> InsOrdHashMap k b -> InsOrdHashMap k a
(a -> b) -> InsOrdHashMap k a -> InsOrdHashMap k b
(forall a b. (a -> b) -> InsOrdHashMap k a -> InsOrdHashMap k b)
-> (forall a b. a -> InsOrdHashMap k b -> InsOrdHashMap k a)
-> Functor (InsOrdHashMap k)
forall a b. a -> InsOrdHashMap k b -> InsOrdHashMap k a
forall a b. (a -> b) -> InsOrdHashMap k a -> InsOrdHashMap k b
forall k a b. a -> InsOrdHashMap k b -> InsOrdHashMap k a
forall k a b. (a -> b) -> InsOrdHashMap k a -> InsOrdHashMap k b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> InsOrdHashMap k b -> InsOrdHashMap k a
$c<$ :: forall k a b. a -> InsOrdHashMap k b -> InsOrdHashMap k a
fmap :: (a -> b) -> InsOrdHashMap k a -> InsOrdHashMap k b
$cfmap :: forall k a b. (a -> b) -> InsOrdHashMap k a -> InsOrdHashMap k b
Functor, Typeable, Typeable (InsOrdHashMap k v)
DataType
Constr
Typeable (InsOrdHashMap k v)
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> InsOrdHashMap k v
-> c (InsOrdHashMap k v))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (InsOrdHashMap k v))
-> (InsOrdHashMap k v -> Constr)
-> (InsOrdHashMap k v -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (InsOrdHashMap k v)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (InsOrdHashMap k v)))
-> ((forall b. Data b => b -> b)
-> InsOrdHashMap k v -> InsOrdHashMap k v)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> InsOrdHashMap k v -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> InsOrdHashMap k v -> r)
-> (forall u.
(forall d. Data d => d -> u) -> InsOrdHashMap k v -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> InsOrdHashMap k v -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> InsOrdHashMap k v -> m (InsOrdHashMap k v))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> InsOrdHashMap k v -> m (InsOrdHashMap k v))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> InsOrdHashMap k v -> m (InsOrdHashMap k v))
-> Data (InsOrdHashMap k v)
InsOrdHashMap k v -> DataType
InsOrdHashMap k v -> Constr
(forall b. Data b => b -> b)
-> InsOrdHashMap k v -> InsOrdHashMap k v
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> InsOrdHashMap k v
-> c (InsOrdHashMap k v)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (InsOrdHashMap k v)
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (InsOrdHashMap 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) -> InsOrdHashMap k v -> u
forall u. (forall d. Data d => d -> u) -> InsOrdHashMap k v -> [u]
forall k v.
(Data k, Data v, Hashable k) =>
Typeable (InsOrdHashMap k v)
forall k v.
(Data k, Data v, Hashable k) =>
InsOrdHashMap k v -> DataType
forall k v.
(Data k, Data v, Hashable k) =>
InsOrdHashMap k v -> Constr
forall k v.
(Data k, Data v, Hashable k) =>
(forall b. Data b => b -> b)
-> InsOrdHashMap k v -> InsOrdHashMap k v
forall k v u.
(Data k, Data v, Hashable k) =>
Int -> (forall d. Data d => d -> u) -> InsOrdHashMap k v -> u
forall k v u.
(Data k, Data v, Hashable k) =>
(forall d. Data d => d -> u) -> InsOrdHashMap k v -> [u]
forall k v r r'.
(Data k, Data v, Hashable k) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> InsOrdHashMap k v -> r
forall k v r r'.
(Data k, Data v, Hashable k) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> InsOrdHashMap k v -> r
forall k v (m :: * -> *).
(Data k, Data v, Hashable k, Monad m) =>
(forall d. Data d => d -> m d)
-> InsOrdHashMap k v -> m (InsOrdHashMap k v)
forall k v (m :: * -> *).
(Data k, Data v, Hashable k, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> InsOrdHashMap k v -> m (InsOrdHashMap k v)
forall k v (c :: * -> *).
(Data k, Data v, Hashable k) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (InsOrdHashMap k v)
forall k v (c :: * -> *).
(Data k, Data v, Hashable k) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> InsOrdHashMap k v
-> c (InsOrdHashMap k v)
forall k v (t :: * -> *) (c :: * -> *).
(Data k, Data v, Hashable k, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (InsOrdHashMap k v))
forall k v (t :: * -> * -> *) (c :: * -> *).
(Data k, Data v, Hashable k, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (InsOrdHashMap k v))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> InsOrdHashMap k v -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> InsOrdHashMap k v -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> InsOrdHashMap k v -> m (InsOrdHashMap k v)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> InsOrdHashMap k v -> m (InsOrdHashMap k v)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (InsOrdHashMap k v)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> InsOrdHashMap k v
-> c (InsOrdHashMap k v)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (InsOrdHashMap k v))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (InsOrdHashMap k v))
$cInsOrdHashMap :: Constr
$tInsOrdHashMap :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> InsOrdHashMap k v -> m (InsOrdHashMap k v)
$cgmapMo :: forall k v (m :: * -> *).
(Data k, Data v, Hashable k, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> InsOrdHashMap k v -> m (InsOrdHashMap k v)
gmapMp :: (forall d. Data d => d -> m d)
-> InsOrdHashMap k v -> m (InsOrdHashMap k v)
$cgmapMp :: forall k v (m :: * -> *).
(Data k, Data v, Hashable k, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> InsOrdHashMap k v -> m (InsOrdHashMap k v)
gmapM :: (forall d. Data d => d -> m d)
-> InsOrdHashMap k v -> m (InsOrdHashMap k v)
$cgmapM :: forall k v (m :: * -> *).
(Data k, Data v, Hashable k, Monad m) =>
(forall d. Data d => d -> m d)
-> InsOrdHashMap k v -> m (InsOrdHashMap k v)
gmapQi :: Int -> (forall d. Data d => d -> u) -> InsOrdHashMap k v -> u
$cgmapQi :: forall k v u.
(Data k, Data v, Hashable k) =>
Int -> (forall d. Data d => d -> u) -> InsOrdHashMap k v -> u
gmapQ :: (forall d. Data d => d -> u) -> InsOrdHashMap k v -> [u]
$cgmapQ :: forall k v u.
(Data k, Data v, Hashable k) =>
(forall d. Data d => d -> u) -> InsOrdHashMap k v -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> InsOrdHashMap k v -> r
$cgmapQr :: forall k v r r'.
(Data k, Data v, Hashable k) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> InsOrdHashMap k v -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> InsOrdHashMap k v -> r
$cgmapQl :: forall k v r r'.
(Data k, Data v, Hashable k) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> InsOrdHashMap k v -> r
gmapT :: (forall b. Data b => b -> b)
-> InsOrdHashMap k v -> InsOrdHashMap k v
$cgmapT :: forall k v.
(Data k, Data v, Hashable k) =>
(forall b. Data b => b -> b)
-> InsOrdHashMap k v -> InsOrdHashMap k v
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (InsOrdHashMap k v))
$cdataCast2 :: forall k v (t :: * -> * -> *) (c :: * -> *).
(Data k, Data v, Hashable k, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (InsOrdHashMap k v))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (InsOrdHashMap k v))
$cdataCast1 :: forall k v (t :: * -> *) (c :: * -> *).
(Data k, Data v, Hashable k, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (InsOrdHashMap k v))
dataTypeOf :: InsOrdHashMap k v -> DataType
$cdataTypeOf :: forall k v.
(Data k, Data v, Hashable k) =>
InsOrdHashMap k v -> DataType
toConstr :: InsOrdHashMap k v -> Constr
$ctoConstr :: forall k v.
(Data k, Data v, Hashable k) =>
InsOrdHashMap k v -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (InsOrdHashMap k v)
$cgunfold :: forall k v (c :: * -> *).
(Data k, Data v, Hashable k) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (InsOrdHashMap k v)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> InsOrdHashMap k v
-> c (InsOrdHashMap k v)
$cgfoldl :: forall k v (c :: * -> *).
(Data k, Data v, Hashable k) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> InsOrdHashMap k v
-> c (InsOrdHashMap k v)
$cp1Data :: forall k v.
(Data k, Data v, Hashable k) =>
Typeable (InsOrdHashMap k v)
Data)
instance (NFData k, NFData v) => NFData (InsOrdHashMap k v) where
rnf :: InsOrdHashMap k v -> ()
rnf (InsOrdHashMap Int
_ HashMap k (P v)
hm) = HashMap k (P v) -> ()
forall a. NFData a => a -> ()
rnf HashMap k (P v)
hm
#if MIN_VERSION_deepseq(1,4,3)
instance NFData k => NF.NFData1 (InsOrdHashMap k) where
liftRnf :: (a -> ()) -> InsOrdHashMap k a -> ()
liftRnf a -> ()
rnf2 = (k -> ()) -> (a -> ()) -> InsOrdHashMap k a -> ()
forall (p :: * -> * -> *) a b.
NFData2 p =>
(a -> ()) -> (b -> ()) -> p a b -> ()
NF.liftRnf2 k -> ()
forall a. NFData a => a -> ()
rnf a -> ()
rnf2
instance NF.NFData2 InsOrdHashMap where
liftRnf2 :: (a -> ()) -> (b -> ()) -> InsOrdHashMap a b -> ()
liftRnf2 a -> ()
rnf1 b -> ()
rnf2 (InsOrdHashMap Int
_ HashMap a (P b)
m) = (a -> ()) -> (P b -> ()) -> HashMap a (P b) -> ()
forall (p :: * -> * -> *) a b.
NFData2 p =>
(a -> ()) -> (b -> ()) -> p a b -> ()
NF.liftRnf2 a -> ()
rnf1 ((b -> ()) -> P b -> ()
forall (f :: * -> *) a. NFData1 f => (a -> ()) -> f a -> ()
NF.liftRnf b -> ()
rnf2) HashMap a (P b)
m
#endif
instance (Eq k, Eq v) => Eq (InsOrdHashMap k v) where
InsOrdHashMap Int
_ HashMap k (P v)
a == :: InsOrdHashMap k v -> InsOrdHashMap k v -> Bool
== InsOrdHashMap Int
_ HashMap k (P v)
b = HashMap k (P v)
a HashMap k (P v) -> HashMap k (P v) -> Bool
forall a. Eq a => a -> a -> Bool
== HashMap k (P v)
b
instance (Show k, Show v) => Show (InsOrdHashMap k v) where
showsPrec :: Int -> InsOrdHashMap k v -> ShowS
showsPrec Int
d InsOrdHashMap k v
m = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"fromList " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> [(k, v)] -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 (InsOrdHashMap k v -> [(k, v)]
forall k v. InsOrdHashMap k v -> [(k, v)]
toList InsOrdHashMap k v
m)
instance (Eq k, Hashable k, Read k, Read v) => Read (InsOrdHashMap k v) where
readPrec :: ReadPrec (InsOrdHashMap k v)
readPrec = ReadPrec (InsOrdHashMap k v) -> ReadPrec (InsOrdHashMap k v)
forall a. ReadPrec a -> ReadPrec a
parens (ReadPrec (InsOrdHashMap k v) -> ReadPrec (InsOrdHashMap k v))
-> ReadPrec (InsOrdHashMap k v) -> ReadPrec (InsOrdHashMap k v)
forall a b. (a -> b) -> a -> b
$ Int -> ReadPrec (InsOrdHashMap k v) -> ReadPrec (InsOrdHashMap k v)
forall a. Int -> ReadPrec a -> ReadPrec a
prec Int
10 (ReadPrec (InsOrdHashMap k v) -> ReadPrec (InsOrdHashMap k v))
-> ReadPrec (InsOrdHashMap k v) -> ReadPrec (InsOrdHashMap k v)
forall a b. (a -> b) -> a -> b
$ do
Ident String
"fromList" <- ReadPrec Lexeme
lexP
[(k, v)]
xs <- ReadPrec [(k, v)]
forall a. Read a => ReadPrec a
readPrec
InsOrdHashMap k v -> ReadPrec (InsOrdHashMap k v)
forall (m :: * -> *) a. Monad m => a -> m a
return ([(k, v)] -> InsOrdHashMap k v
forall k v. (Eq k, Hashable k) => [(k, v)] -> InsOrdHashMap k v
fromList [(k, v)]
xs)
readListPrec :: ReadPrec [InsOrdHashMap k v]
readListPrec = ReadPrec [InsOrdHashMap k v]
forall a. Read a => ReadPrec [a]
readListPrecDefault
instance (Eq k, Hashable k) => Semigroup (InsOrdHashMap k v) where
<> :: InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
(<>) = InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
forall k v.
(Eq k, Hashable k) =>
InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
union
instance (Eq k, Hashable k) => Monoid (InsOrdHashMap k v) where
mempty :: InsOrdHashMap k v
mempty = InsOrdHashMap k v
forall k v. InsOrdHashMap k v
empty
mappend :: InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
mappend = InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
forall k v.
(Eq k, Hashable k) =>
InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
union
instance Foldable (InsOrdHashMap k) where
foldMap :: (a -> m) -> InsOrdHashMap k a -> m
foldMap a -> m
f = ((k, a) -> m) -> [(k, a)] -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (a -> m
f (a -> m) -> ((k, a) -> a) -> (k, a) -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (k, a) -> a
forall a b. (a, b) -> b
snd) ([(k, a)] -> m)
-> (InsOrdHashMap k a -> [(k, a)]) -> InsOrdHashMap k a -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InsOrdHashMap k a -> [(k, a)]
forall k v. InsOrdHashMap k v -> [(k, v)]
toList
null :: InsOrdHashMap k a -> Bool
null = InsOrdHashMap k a -> Bool
forall k a. InsOrdHashMap k a -> Bool
null
toList :: InsOrdHashMap k a -> [a]
toList = InsOrdHashMap k a -> [a]
forall k a. InsOrdHashMap k a -> [a]
elems
length :: InsOrdHashMap k a -> Int
length = InsOrdHashMap k a -> Int
forall k a. InsOrdHashMap k a -> Int
size
instance Traversable (InsOrdHashMap k) where
traverse :: (a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
traverse a -> f b
f InsOrdHashMap k a
m = (k -> a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
forall (f :: * -> *) k a b.
Applicative f =>
(k -> a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
traverseWithKey (\k
_ -> a -> f b
f) InsOrdHashMap k a
m
instance (Eq k, Hashable k) => Apply (InsOrdHashMap k) where
<.> :: InsOrdHashMap k (a -> b) -> InsOrdHashMap k a -> InsOrdHashMap k b
(<.>) = ((a -> b) -> a -> b)
-> InsOrdHashMap k (a -> b)
-> InsOrdHashMap k a
-> InsOrdHashMap k b
forall k v1 v2 v3.
(Eq k, Hashable k) =>
(v1 -> v2 -> v3)
-> InsOrdHashMap k v1 -> InsOrdHashMap k v2 -> InsOrdHashMap k v3
intersectionWith (a -> b) -> a -> b
forall a. a -> a
id
(<. ) = (a -> b -> a)
-> InsOrdHashMap k a -> InsOrdHashMap k b -> InsOrdHashMap k a
forall k v1 v2 v3.
(Eq k, Hashable k) =>
(v1 -> v2 -> v3)
-> InsOrdHashMap k v1 -> InsOrdHashMap k v2 -> InsOrdHashMap k v3
intersectionWith a -> b -> a
forall a b. a -> b -> a
const
( .>) = (a -> b -> b)
-> InsOrdHashMap k a -> InsOrdHashMap k b -> InsOrdHashMap k b
forall k v1 v2 v3.
(Eq k, Hashable k) =>
(v1 -> v2 -> v3)
-> InsOrdHashMap k v1 -> InsOrdHashMap k v2 -> InsOrdHashMap k v3
intersectionWith ((b -> b) -> a -> b -> b
forall a b. a -> b -> a
const b -> b
forall a. a -> a
id)
instance (Eq k, Hashable k) => Bind (InsOrdHashMap k) where
InsOrdHashMap k a
m >>- :: InsOrdHashMap k a -> (a -> InsOrdHashMap k b) -> InsOrdHashMap k b
>>- a -> InsOrdHashMap k b
f = (k -> a -> Maybe b) -> InsOrdHashMap k a -> InsOrdHashMap k b
forall k v1 v2.
(k -> v1 -> Maybe v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2
mapMaybeWithKey (\k
k -> k -> InsOrdHashMap k b -> Maybe b
forall k v. (Eq k, Hashable k) => k -> InsOrdHashMap k v -> Maybe v
lookup k
k (InsOrdHashMap k b -> Maybe b)
-> (a -> InsOrdHashMap k b) -> a -> Maybe b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> InsOrdHashMap k b
f) InsOrdHashMap k a
m
instance (Hashable k, Hashable v) => Hashable (InsOrdHashMap k v) where
hashWithSalt :: Int -> InsOrdHashMap k v -> Int
hashWithSalt Int
salt (InsOrdHashMap Int
_ HashMap k (P v)
m) =
Int -> HashMap k (P v) -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
salt HashMap k (P v)
m
instance (Eq k, Hashable k) => Exts.IsList (InsOrdHashMap k v) where
type Item (InsOrdHashMap k v) = (k, v)
fromList :: [Item (InsOrdHashMap k v)] -> InsOrdHashMap k v
fromList = [Item (InsOrdHashMap k v)] -> InsOrdHashMap k v
forall k v. (Eq k, Hashable k) => [(k, v)] -> InsOrdHashMap k v
fromList
toList :: InsOrdHashMap k v -> [Item (InsOrdHashMap k v)]
toList = InsOrdHashMap k v -> [Item (InsOrdHashMap k v)]
forall k v. InsOrdHashMap k v -> [(k, v)]
toList
instance (ToJSONKey k) => ToJSON1 (InsOrdHashMap k) where
liftToJSON :: (a -> Value) -> ([a] -> Value) -> InsOrdHashMap k a -> Value
liftToJSON a -> Value
t [a] -> Value
_ = case ToJSONKeyFunction k
forall a. ToJSONKey a => ToJSONKeyFunction a
toJSONKey :: ToJSONKeyFunction k of
ToJSONKeyText k -> Key
f k -> Encoding' Key
_ -> [Pair] -> Value
object ([Pair] -> Value)
-> (InsOrdHashMap k a -> [Pair]) -> InsOrdHashMap k a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((k, a) -> Pair) -> [(k, a)] -> [Pair]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(k
k, a
v) -> (k -> Key
f k
k, a -> Value
t a
v)) ([(k, a)] -> [Pair])
-> (InsOrdHashMap k a -> [(k, a)]) -> InsOrdHashMap k a -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InsOrdHashMap k a -> [(k, a)]
forall k v. InsOrdHashMap k v -> [(k, v)]
toList
ToJSONKeyValue k -> Value
f k -> Encoding
_ -> [Value] -> Value
forall a. ToJSON a => a -> Value
toJSON ([Value] -> Value)
-> (InsOrdHashMap k a -> [Value]) -> InsOrdHashMap k a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((k, a) -> Value) -> [(k, a)] -> [Value]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(k
k,a
v) -> (Value, Value) -> Value
forall a. ToJSON a => a -> Value
toJSON (k -> Value
f k
k, a -> Value
t a
v)) ([(k, a)] -> [Value])
-> (InsOrdHashMap k a -> [(k, a)]) -> InsOrdHashMap k a -> [Value]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InsOrdHashMap k a -> [(k, a)]
forall k v. InsOrdHashMap k v -> [(k, v)]
toList
liftToEncoding :: (a -> Encoding)
-> ([a] -> Encoding) -> InsOrdHashMap k a -> Encoding
liftToEncoding a -> Encoding
t [a] -> Encoding
_ = case ToJSONKeyFunction k
forall a. ToJSONKey a => ToJSONKeyFunction a
toJSONKey :: ToJSONKeyFunction k of
ToJSONKeyText k -> Key
_ k -> Encoding' Key
f -> (k -> Encoding' Key)
-> (a -> Encoding)
-> (forall a. (k -> a -> a -> a) -> a -> InsOrdHashMap k a -> a)
-> InsOrdHashMap k a
-> Encoding
forall k v m.
(k -> Encoding' Key)
-> (v -> Encoding)
-> (forall a. (k -> v -> a -> a) -> a -> m -> a)
-> m
-> Encoding
E.dict k -> Encoding' Key
f a -> Encoding
t forall a. (k -> a -> a -> a) -> a -> InsOrdHashMap k a -> a
forall k v a. (k -> v -> a -> a) -> a -> InsOrdHashMap k v -> a
foldrWithKey
ToJSONKeyValue k -> Value
_ k -> Encoding
f -> ((k, a) -> Encoding) -> [(k, a)] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list ((k -> Encoding)
-> ([k] -> Encoding)
-> (a -> Encoding)
-> ([a] -> Encoding)
-> (k, a)
-> Encoding
forall (f :: * -> * -> *) a b.
ToJSON2 f =>
(a -> Encoding)
-> ([a] -> Encoding)
-> (b -> Encoding)
-> ([b] -> Encoding)
-> f a b
-> Encoding
liftToEncoding2 k -> Encoding
f ((k -> Encoding) -> [k] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list k -> Encoding
f) a -> Encoding
t ((a -> Encoding) -> [a] -> Encoding
forall a. (a -> Encoding) -> [a] -> Encoding
E.list a -> Encoding
t)) ([(k, a)] -> Encoding)
-> (InsOrdHashMap k a -> [(k, a)]) -> InsOrdHashMap k a -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InsOrdHashMap k a -> [(k, a)]
forall k v. InsOrdHashMap k v -> [(k, v)]
toList
instance (ToJSONKey k, ToJSON v) => ToJSON (InsOrdHashMap k v) where
toJSON :: InsOrdHashMap k v -> Value
toJSON = InsOrdHashMap k v -> Value
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Value
toJSON1
toEncoding :: InsOrdHashMap k v -> Encoding
toEncoding = InsOrdHashMap k v -> Encoding
forall (f :: * -> *) a. (ToJSON1 f, ToJSON a) => f a -> Encoding
toEncoding1
instance (Eq k, Hashable k, FromJSONKey k) => FromJSON1 (InsOrdHashMap k) where
liftParseJSON :: (Value -> Parser a)
-> (Value -> Parser [a]) -> Value -> Parser (InsOrdHashMap k a)
liftParseJSON Value -> Parser a
p Value -> Parser [a]
pl Value
v = [(k, a)] -> InsOrdHashMap k a
forall k v. (Eq k, Hashable k) => [(k, v)] -> InsOrdHashMap k v
fromList ([(k, a)] -> InsOrdHashMap k a)
-> (HashMap k a -> [(k, a)]) -> HashMap k a -> InsOrdHashMap k a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashMap k a -> [(k, a)]
forall k v. HashMap k v -> [(k, v)]
HashMap.toList (HashMap k a -> InsOrdHashMap k a)
-> Parser (HashMap k a) -> Parser (InsOrdHashMap k a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value -> Parser a)
-> (Value -> Parser [a]) -> Value -> Parser (HashMap k a)
forall (f :: * -> *) a.
FromJSON1 f =>
(Value -> Parser a)
-> (Value -> Parser [a]) -> Value -> Parser (f a)
liftParseJSON Value -> Parser a
p Value -> Parser [a]
pl Value
v
instance (Eq k, Hashable k, FromJSONKey k, FromJSON v) => FromJSON (InsOrdHashMap k v) where
parseJSON :: Value -> Parser (InsOrdHashMap k v)
parseJSON = Value -> Parser (InsOrdHashMap k v)
forall (f :: * -> *) a.
(FromJSON1 f, FromJSON a) =>
Value -> Parser (f a)
parseJSON1
instance (Eq k, Hashable k) => FunctorWithIndex k (InsOrdHashMap k) where
imap :: (k -> a -> b) -> InsOrdHashMap k a -> InsOrdHashMap k b
imap = (k -> a -> b) -> InsOrdHashMap k a -> InsOrdHashMap k b
forall k v1 v2.
(k -> v1 -> v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2
mapWithKey
instance (Eq k, Hashable k) => FoldableWithIndex k (InsOrdHashMap k) where
ifoldMap :: (k -> a -> m) -> InsOrdHashMap k a -> m
ifoldMap = (k -> a -> m) -> InsOrdHashMap k a -> m
forall m k a. Monoid m => (k -> a -> m) -> InsOrdHashMap k a -> m
foldMapWithKey
ifoldr :: (k -> a -> b -> b) -> b -> InsOrdHashMap k a -> b
ifoldr = (k -> a -> b -> b) -> b -> InsOrdHashMap k a -> b
forall k v a. (k -> v -> a -> a) -> a -> InsOrdHashMap k v -> a
foldrWithKey
instance (Eq k, Hashable k) => TraversableWithIndex k (InsOrdHashMap k) where
itraverse :: (k -> a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
itraverse = (k -> a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
forall (f :: * -> *) k a b.
Applicative f =>
(k -> a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
traverseWithKey
type instance Index (InsOrdHashMap k v) = k
type instance IxValue (InsOrdHashMap k v) = v
instance (Eq k, Hashable k) => Ixed (InsOrdHashMap k v) where
ix :: Index (InsOrdHashMap k v)
-> Traversal' (InsOrdHashMap k v) (IxValue (InsOrdHashMap k v))
ix Index (InsOrdHashMap k v)
k IxValue (InsOrdHashMap k v) -> f (IxValue (InsOrdHashMap k v))
f InsOrdHashMap k v
m = k
-> (InsOrdHashMap k v -> f (InsOrdHashMap k v))
-> (v -> f v)
-> InsOrdHashMap k v
-> f (InsOrdHashMap k v)
forall k (f :: * -> *) v.
(Eq k, Hashable k, Functor f) =>
k
-> (InsOrdHashMap k v -> f (InsOrdHashMap k v))
-> (v -> f v)
-> InsOrdHashMap k v
-> f (InsOrdHashMap k v)
ixImpl k
Index (InsOrdHashMap k v)
k InsOrdHashMap k v -> f (InsOrdHashMap k v)
forall (f :: * -> *) a. Applicative f => a -> f a
pure v -> f v
IxValue (InsOrdHashMap k v) -> f (IxValue (InsOrdHashMap k v))
f InsOrdHashMap k v
m
{-# INLINABLE ix #-}
ixImpl
:: (Eq k, Hashable k, Functor f)
=> k
-> (InsOrdHashMap k v -> f (InsOrdHashMap k v))
-> (v -> f v)
-> InsOrdHashMap k v
-> f (InsOrdHashMap k v)
ixImpl :: k
-> (InsOrdHashMap k v -> f (InsOrdHashMap k v))
-> (v -> f v)
-> InsOrdHashMap k v
-> f (InsOrdHashMap k v)
ixImpl k
k InsOrdHashMap k v -> f (InsOrdHashMap k v)
point v -> f v
f InsOrdHashMap k v
m = case k -> InsOrdHashMap k v -> Maybe v
forall k v. (Eq k, Hashable k) => k -> InsOrdHashMap k v -> Maybe v
lookup k
k InsOrdHashMap k v
m of
Just v
v -> v -> f v
f v
v f v -> (v -> InsOrdHashMap k v) -> f (InsOrdHashMap k v)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \v
v' -> k -> v -> InsOrdHashMap k v -> InsOrdHashMap k v
forall k v.
(Eq k, Hashable k) =>
k -> v -> InsOrdHashMap k v -> InsOrdHashMap k v
insert k
k v
v' InsOrdHashMap k v
m
Maybe v
Nothing -> InsOrdHashMap k v -> f (InsOrdHashMap k v)
point InsOrdHashMap k v
m
{-# INLINE ixImpl #-}
instance (Eq k, Hashable k) => At (InsOrdHashMap k a) where
at :: Index (InsOrdHashMap k a)
-> Lens' (InsOrdHashMap k a) (Maybe (IxValue (InsOrdHashMap k a)))
at Index (InsOrdHashMap k a)
k Maybe (IxValue (InsOrdHashMap k a))
-> f (Maybe (IxValue (InsOrdHashMap k a)))
f InsOrdHashMap k a
m = Maybe (IxValue (InsOrdHashMap k a))
-> f (Maybe (IxValue (InsOrdHashMap k a)))
f Maybe a
Maybe (IxValue (InsOrdHashMap k a))
mv f (Maybe a)
-> (Maybe a -> InsOrdHashMap k a) -> f (InsOrdHashMap k a)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Maybe a
r -> case Maybe a
r of
Maybe a
Nothing -> InsOrdHashMap k a
-> (a -> InsOrdHashMap k a) -> Maybe a -> InsOrdHashMap k a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe InsOrdHashMap k a
m (InsOrdHashMap k a -> a -> InsOrdHashMap k a
forall a b. a -> b -> a
const (k -> InsOrdHashMap k a -> InsOrdHashMap k a
forall k v.
(Eq k, Hashable k) =>
k -> InsOrdHashMap k v -> InsOrdHashMap k v
delete k
Index (InsOrdHashMap k a)
k InsOrdHashMap k a
m)) Maybe a
mv
Just a
v' -> k -> a -> InsOrdHashMap k a -> InsOrdHashMap k a
forall k v.
(Eq k, Hashable k) =>
k -> v -> InsOrdHashMap k v -> InsOrdHashMap k v
insert k
Index (InsOrdHashMap k a)
k a
v' InsOrdHashMap k a
m
where mv :: Maybe a
mv = k -> InsOrdHashMap k a -> Maybe a
forall k v. (Eq k, Hashable k) => k -> InsOrdHashMap k v -> Maybe v
lookup k
Index (InsOrdHashMap k a)
k InsOrdHashMap k a
m
{-# INLINABLE at #-}
hashMap :: Iso (InsOrdHashMap k a) (InsOrdHashMap k b) (HashMap k a) (HashMap k b)
hashMap :: p (HashMap k a) (f (HashMap k b))
-> p (InsOrdHashMap k a) (f (InsOrdHashMap k b))
hashMap = (InsOrdHashMap k a -> HashMap k a)
-> (HashMap k b -> InsOrdHashMap k b)
-> Iso
(InsOrdHashMap k a) (InsOrdHashMap k b) (HashMap k a) (HashMap k b)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso InsOrdHashMap k a -> HashMap k a
forall k v. InsOrdHashMap k v -> HashMap k v
toHashMap HashMap k b -> InsOrdHashMap k b
forall k v. HashMap k v -> InsOrdHashMap k v
fromHashMap
unorderedTraversal :: Traversal (InsOrdHashMap k a) (InsOrdHashMap k b) a b
unorderedTraversal :: (a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
unorderedTraversal = (HashMap k a -> f (HashMap k b))
-> InsOrdHashMap k a -> f (InsOrdHashMap k b)
forall k a b.
Iso
(InsOrdHashMap k a) (InsOrdHashMap k b) (HashMap k a) (HashMap k b)
hashMap ((HashMap k a -> f (HashMap k b))
-> InsOrdHashMap k a -> f (InsOrdHashMap k b))
-> ((a -> f b) -> HashMap k a -> f (HashMap k b))
-> (a -> f b)
-> InsOrdHashMap k a
-> f (InsOrdHashMap k b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f b) -> HashMap k a -> f (HashMap k b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse
#if !MIN_VERSION_lens(5,0,0)
instance (Eq k, Hashable k) => Lens.FunctorWithIndex k (InsOrdHashMap k) where
imap = mapWithKey
instance (Eq k, Hashable k) => Lens.FoldableWithIndex k (InsOrdHashMap k) where
ifoldMap = foldMapWithKey
ifoldr = foldrWithKey
instance (Eq k, Hashable k) => Lens.TraversableWithIndex k (InsOrdHashMap k) where
itraverse = traverseWithKey
#endif
type instance Optics.Index (InsOrdHashMap k v) = k
type instance Optics.IxValue (InsOrdHashMap k v) = v
instance (Eq k, Hashable k) => Optics.Ixed (InsOrdHashMap k v) where
ix :: Index (InsOrdHashMap k v)
-> Optic'
(IxKind (InsOrdHashMap k v))
NoIx
(InsOrdHashMap k v)
(IxValue (InsOrdHashMap k v))
ix Index (InsOrdHashMap k v)
k = AffineTraversalVL (InsOrdHashMap k v) (InsOrdHashMap k v) v v
-> AffineTraversal (InsOrdHashMap k v) (InsOrdHashMap k v) v v
forall s t a b.
AffineTraversalVL s t a b -> AffineTraversal s t a b
Optics.atraversalVL (AffineTraversalVL (InsOrdHashMap k v) (InsOrdHashMap k v) v v
-> AffineTraversal (InsOrdHashMap k v) (InsOrdHashMap k v) v v)
-> AffineTraversalVL (InsOrdHashMap k v) (InsOrdHashMap k v) v v
-> AffineTraversal (InsOrdHashMap k v) (InsOrdHashMap k v) v v
forall a b. (a -> b) -> a -> b
$ \forall r. r -> f r
point v -> f v
f InsOrdHashMap k v
m -> k
-> (InsOrdHashMap k v -> f (InsOrdHashMap k v))
-> (v -> f v)
-> InsOrdHashMap k v
-> f (InsOrdHashMap k v)
forall k (f :: * -> *) v.
(Eq k, Hashable k, Functor f) =>
k
-> (InsOrdHashMap k v -> f (InsOrdHashMap k v))
-> (v -> f v)
-> InsOrdHashMap k v
-> f (InsOrdHashMap k v)
ixImpl k
Index (InsOrdHashMap k v)
k InsOrdHashMap k v -> f (InsOrdHashMap k v)
forall r. r -> f r
point v -> f v
f InsOrdHashMap k v
m
{-# INLINE ix #-}
instance (Eq k, Hashable k) => Optics.At (InsOrdHashMap k a) where
at :: Index (InsOrdHashMap k a)
-> Lens' (InsOrdHashMap k a) (Maybe (IxValue (InsOrdHashMap k a)))
at Index (InsOrdHashMap k a)
k = LensVL (InsOrdHashMap k a) (InsOrdHashMap k a) (Maybe a) (Maybe a)
-> Lens (InsOrdHashMap k a) (InsOrdHashMap k a) (Maybe a) (Maybe a)
forall s t a b. LensVL s t a b -> Lens s t a b
Optics.lensVL (LensVL (InsOrdHashMap k a) (InsOrdHashMap k a) (Maybe a) (Maybe a)
-> Lens
(InsOrdHashMap k a) (InsOrdHashMap k a) (Maybe a) (Maybe a))
-> LensVL
(InsOrdHashMap k a) (InsOrdHashMap k a) (Maybe a) (Maybe a)
-> Lens (InsOrdHashMap k a) (InsOrdHashMap k a) (Maybe a) (Maybe a)
forall a b. (a -> b) -> a -> b
$ \Maybe a -> f (Maybe a)
f InsOrdHashMap k a
m -> Index (InsOrdHashMap k a)
-> (Maybe (IxValue (InsOrdHashMap k a))
-> f (Maybe (IxValue (InsOrdHashMap k a))))
-> InsOrdHashMap k a
-> f (InsOrdHashMap k a)
forall m. At m => Index m -> Lens' m (Maybe (IxValue m))
Lens.at Index (InsOrdHashMap k a)
Index (InsOrdHashMap k a)
k Maybe a -> f (Maybe a)
Maybe (IxValue (InsOrdHashMap k a))
-> f (Maybe (IxValue (InsOrdHashMap k a)))
f InsOrdHashMap k a
m
{-# INLINE at #-}
#if !MIN_VERSION_optics_core(0,4,0)
instance (Eq k, Hashable k) => Optics.FunctorWithIndex k (InsOrdHashMap k) where
imap = mapWithKey
instance (Eq k, Hashable k) => Optics.FoldableWithIndex k (InsOrdHashMap k) where
ifoldMap = foldMapWithKey
ifoldr = foldrWithKey
instance (Eq k, Hashable k) => Optics.TraversableWithIndex k (InsOrdHashMap k) where
itraverse = traverseWithKey
#endif
empty :: InsOrdHashMap k v
empty :: InsOrdHashMap k v
empty = Int -> HashMap k (P v) -> InsOrdHashMap k v
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
0 HashMap k (P v)
forall k v. HashMap k v
HashMap.empty
{-# INLINABLE empty #-}
singleton :: Hashable k => k -> v -> InsOrdHashMap k v
singleton :: k -> v -> InsOrdHashMap k v
singleton k
k v
v = Int -> HashMap k (P v) -> InsOrdHashMap k v
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
1 (k -> P v -> HashMap k (P v)
forall k v. Hashable k => k -> v -> HashMap k v
HashMap.singleton k
k (Int -> v -> P v
forall a. Int -> a -> P a
P Int
0 v
v))
{-# INLINABLE singleton #-}
null :: InsOrdHashMap k v -> Bool
null :: InsOrdHashMap k v -> Bool
null = HashMap k (P v) -> Bool
forall k v. HashMap k v -> Bool
HashMap.null (HashMap k (P v) -> Bool)
-> (InsOrdHashMap k v -> HashMap k (P v))
-> InsOrdHashMap k v
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InsOrdHashMap k v -> HashMap k (P v)
forall k v. InsOrdHashMap k v -> HashMap k (P v)
getInsOrdHashMap
{-# INLINABLE null #-}
size :: InsOrdHashMap k v -> Int
size :: InsOrdHashMap k v -> Int
size = HashMap k (P v) -> Int
forall k v. HashMap k v -> Int
HashMap.size (HashMap k (P v) -> Int)
-> (InsOrdHashMap k v -> HashMap k (P v))
-> InsOrdHashMap k v
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InsOrdHashMap k v -> HashMap k (P v)
forall k v. InsOrdHashMap k v -> HashMap k (P v)
getInsOrdHashMap
{-# INLINABLE size #-}
member :: (Eq k, Hashable k) => k -> InsOrdHashMap k a -> Bool
member :: k -> InsOrdHashMap k a -> Bool
member k
k = k -> HashMap k (P a) -> Bool
forall k a. (Eq k, Hashable k) => k -> HashMap k a -> Bool
HashMap.member k
k (HashMap k (P a) -> Bool)
-> (InsOrdHashMap k a -> HashMap k (P a))
-> InsOrdHashMap k a
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InsOrdHashMap k a -> HashMap k (P a)
forall k v. InsOrdHashMap k v -> HashMap k (P v)
getInsOrdHashMap
{-# INLINABLE member #-}
lookup :: (Eq k, Hashable k) => k -> InsOrdHashMap k v -> Maybe v
lookup :: k -> InsOrdHashMap k v -> Maybe v
lookup k
k = (P v -> v) -> Maybe (P v) -> Maybe v
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap P v -> v
forall a. P a -> a
getPV (Maybe (P v) -> Maybe v)
-> (InsOrdHashMap k v -> Maybe (P v))
-> InsOrdHashMap k v
-> Maybe v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. k -> HashMap k (P v) -> Maybe (P v)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
HashMap.lookup k
k (HashMap k (P v) -> Maybe (P v))
-> (InsOrdHashMap k v -> HashMap k (P v))
-> InsOrdHashMap k v
-> Maybe (P v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InsOrdHashMap k v -> HashMap k (P v)
forall k v. InsOrdHashMap k v -> HashMap k (P v)
getInsOrdHashMap
{-# INLINABLE lookup #-}
lookupDefault
:: (Eq k, Hashable k)
=> v
-> k -> InsOrdHashMap k v -> v
lookupDefault :: v -> k -> InsOrdHashMap k v -> v
lookupDefault v
def k
k InsOrdHashMap k v
m = v -> Maybe v -> v
forall a. a -> Maybe a -> a
fromMaybe v
def (Maybe v -> v) -> Maybe v -> v
forall a b. (a -> b) -> a -> b
$ k -> InsOrdHashMap k v -> Maybe v
forall k v. (Eq k, Hashable k) => k -> InsOrdHashMap k v -> Maybe v
lookup k
k InsOrdHashMap k v
m
{-# INLINABLE lookupDefault #-}
delete :: (Eq k, Hashable k) => k -> InsOrdHashMap k v -> InsOrdHashMap k v
delete :: k -> InsOrdHashMap k v -> InsOrdHashMap k v
delete k
k (InsOrdHashMap Int
i HashMap k (P v)
m) = Int -> HashMap k (P v) -> InsOrdHashMap k v
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
i (HashMap k (P v) -> InsOrdHashMap k v)
-> HashMap k (P v) -> InsOrdHashMap k v
forall a b. (a -> b) -> a -> b
$ k -> HashMap k (P v) -> HashMap k (P v)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
HashMap.delete k
k HashMap k (P v)
m
{-# INLINABLE delete #-}
insert :: (Eq k, Hashable k) => k -> v -> InsOrdHashMap k v -> InsOrdHashMap k v
insert :: k -> v -> InsOrdHashMap k v -> InsOrdHashMap k v
insert = (v -> v -> v) -> k -> v -> InsOrdHashMap k v -> InsOrdHashMap k v
forall k v.
(Eq k, Hashable k) =>
(v -> v -> v) -> k -> v -> InsOrdHashMap k v -> InsOrdHashMap k v
insertWith v -> v -> v
forall a b. a -> b -> a
const
{-# INLINABLE insert #-}
insertWith
:: (Eq k, Hashable k)
=> (v -> v -> v) -> k -> v -> InsOrdHashMap k v -> InsOrdHashMap k v
insertWith :: (v -> v -> v) -> k -> v -> InsOrdHashMap k v -> InsOrdHashMap k v
insertWith v -> v -> v
f k
k v
v = (Maybe v -> Maybe v) -> k -> InsOrdHashMap k v -> InsOrdHashMap k v
forall k v.
(Eq k, Hashable k) =>
(Maybe v -> Maybe v) -> k -> InsOrdHashMap k v -> InsOrdHashMap k v
alter (v -> Maybe v
forall a. a -> Maybe a
Just (v -> Maybe v) -> (Maybe v -> v) -> Maybe v -> Maybe v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> (v -> v) -> Maybe v -> v
forall b a. b -> (a -> b) -> Maybe a -> b
maybe v
v (v -> v -> v
f v
v)) k
k
{-# INLINABLE insertWith #-}
adjust
:: (Eq k, Hashable k)
=> (v -> v) -> k -> InsOrdHashMap k v -> InsOrdHashMap k v
adjust :: (v -> v) -> k -> InsOrdHashMap k v -> InsOrdHashMap k v
adjust v -> v
f = (Maybe v -> Maybe v) -> k -> InsOrdHashMap k v -> InsOrdHashMap k v
forall k v.
(Eq k, Hashable k) =>
(Maybe v -> Maybe v) -> k -> InsOrdHashMap k v -> InsOrdHashMap k v
alter ((v -> v) -> Maybe v -> Maybe v
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap v -> v
f)
{-# INLINABLE adjust #-}
update
:: (Eq k, Hashable k)
=> (a -> Maybe a) -> k -> InsOrdHashMap k a -> InsOrdHashMap k a
update :: (a -> Maybe a) -> k -> InsOrdHashMap k a -> InsOrdHashMap k a
update a -> Maybe a
f = (Maybe a -> Maybe a) -> k -> InsOrdHashMap k a -> InsOrdHashMap k a
forall k v.
(Eq k, Hashable k) =>
(Maybe v -> Maybe v) -> k -> InsOrdHashMap k v -> InsOrdHashMap k v
alter (Maybe a -> (a -> Maybe a) -> Maybe a
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= a -> Maybe a
f)
{-# INLINABLE update #-}
alter
:: (Eq k, Hashable k)
=> (Maybe v -> Maybe v) -> k -> InsOrdHashMap k v -> InsOrdHashMap k v
alter :: (Maybe v -> Maybe v) -> k -> InsOrdHashMap k v -> InsOrdHashMap k v
alter Maybe v -> Maybe v
f k
k insm :: InsOrdHashMap k v
insm@(InsOrdHashMap Int
j HashMap k (P v)
m) =
case k -> HashMap k (P v) -> Maybe (P v)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
HashMap.lookup k
k HashMap k (P v)
m of
Maybe (P v)
Nothing -> case Maybe v -> Maybe v
f Maybe v
forall a. Maybe a
Nothing of
Maybe v
Nothing -> InsOrdHashMap k v
insm
Just v
v -> Int -> HashMap k (P v) -> InsOrdHashMap k v
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap (Int
j Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) (k -> P v -> HashMap k (P v) -> HashMap k (P v)
forall k v.
(Eq k, Hashable k) =>
k -> v -> HashMap k v -> HashMap k v
HashMap.insert k
k (Int -> v -> P v
forall a. Int -> a -> P a
P Int
j v
v) HashMap k (P v)
m)
Just (P Int
i v
v) -> case Maybe v -> Maybe v
f (v -> Maybe v
forall a. a -> Maybe a
Just v
v) of
Maybe v
Nothing -> Int -> HashMap k (P v) -> InsOrdHashMap k v
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
j (k -> HashMap k (P v) -> HashMap k (P v)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
HashMap.delete k
k HashMap k (P v)
m)
Just v
u -> Int -> HashMap k (P v) -> InsOrdHashMap k v
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
j (k -> P v -> HashMap k (P v) -> HashMap k (P v)
forall k v.
(Eq k, Hashable k) =>
k -> v -> HashMap k v -> HashMap k v
HashMap.insert k
k (Int -> v -> P v
forall a. Int -> a -> P a
P Int
i v
u) HashMap k (P v)
m)
{-# INLINABLE alter #-}
unionWith
:: (Eq k, Hashable k)
=> (v -> v -> v)
-> InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
unionWith :: (v -> v -> v)
-> InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
unionWith v -> v -> v
f (InsOrdHashMap Int
i HashMap k (P v)
a) (InsOrdHashMap Int
j HashMap k (P v)
b) =
HashMap k (P v) -> InsOrdHashMap k v
mk (HashMap k (P v) -> InsOrdHashMap k v)
-> HashMap k (P v) -> InsOrdHashMap k v
forall a b. (a -> b) -> a -> b
$ (P v -> P v -> P v)
-> HashMap k (P v) -> HashMap k (P v) -> HashMap k (P v)
forall k v.
(Eq k, Hashable k) =>
(v -> v -> v) -> HashMap k v -> HashMap k v -> HashMap k v
HashMap.unionWith P v -> P v -> P v
f' HashMap k (P v)
a HashMap k (P v)
b'
where
mk :: HashMap k (P v) -> InsOrdHashMap k v
mk | Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0xfffff Bool -> Bool -> Bool
|| Int
j Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
0xfffff = HashMap k (P v) -> InsOrdHashMap k v
forall k v. HashMap k (P v) -> InsOrdHashMap k v
fromHashMapP
| Bool
otherwise = Int -> HashMap k (P v) -> InsOrdHashMap k v
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
j)
b' :: HashMap k (P v)
b' = (P v -> P v) -> HashMap k (P v) -> HashMap k (P v)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Int -> P v -> P v
forall a. Int -> P a -> P a
incPK Int
i) HashMap k (P v)
b
f' :: P v -> P v -> P v
f' (P Int
ii v
x) (P Int
_ v
y) = Int -> v -> P v
forall a. Int -> a -> P a
P Int
ii (v -> v -> v
f v
x v
y)
unionWithKey
:: (Eq k, Hashable k)
=> (k -> v -> v -> v)
-> InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
unionWithKey :: (k -> v -> v -> v)
-> InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
unionWithKey k -> v -> v -> v
f (InsOrdHashMap Int
i HashMap k (P v)
a) (InsOrdHashMap Int
j HashMap k (P v)
b) =
Int -> HashMap k (P v) -> InsOrdHashMap k v
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
j) (HashMap k (P v) -> InsOrdHashMap k v)
-> HashMap k (P v) -> InsOrdHashMap k v
forall a b. (a -> b) -> a -> b
$ (k -> P v -> P v -> P v)
-> HashMap k (P v) -> HashMap k (P v) -> HashMap k (P v)
forall k v.
(Eq k, Hashable k) =>
(k -> v -> v -> v) -> HashMap k v -> HashMap k v -> HashMap k v
HashMap.unionWithKey k -> P v -> P v -> P v
f' HashMap k (P v)
a HashMap k (P v)
b'
where
b' :: HashMap k (P v)
b' = (P v -> P v) -> HashMap k (P v) -> HashMap k (P v)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Int -> P v -> P v
forall a. Int -> P a -> P a
incPK Int
i) HashMap k (P v)
b
f' :: k -> P v -> P v -> P v
f' k
k (P Int
ii v
x) (P Int
_ v
y) = Int -> v -> P v
forall a. Int -> a -> P a
P Int
ii (k -> v -> v -> v
f k
k v
x v
y)
union
:: (Eq k, Hashable k)
=> InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
union :: InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
union = (v -> v -> v)
-> InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
forall k v.
(Eq k, Hashable k) =>
(v -> v -> v)
-> InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
unionWith v -> v -> v
forall a b. a -> b -> a
const
unions
:: (Eq k, Hashable k, Foldable f)
=> f (InsOrdHashMap k v) -> InsOrdHashMap k v
unions :: f (InsOrdHashMap k v) -> InsOrdHashMap k v
unions = (InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v)
-> InsOrdHashMap k v -> f (InsOrdHashMap k v) -> InsOrdHashMap k v
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
F.foldl' InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
forall k v.
(Eq k, Hashable k) =>
InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
union InsOrdHashMap k v
forall k v. InsOrdHashMap k v
empty
mapKeys :: (Eq k', Hashable k') => (k -> k') -> InsOrdHashMap k v -> InsOrdHashMap k' v
mapKeys :: (k -> k') -> InsOrdHashMap k v -> InsOrdHashMap k' v
mapKeys k -> k'
f (InsOrdHashMap Int
i HashMap k (P v)
m) = Int -> HashMap k' (P v) -> InsOrdHashMap k' v
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
i (HashMap k' (P v) -> InsOrdHashMap k' v)
-> HashMap k' (P v) -> InsOrdHashMap k' v
forall a b. (a -> b) -> a -> b
$
[(k', P v)] -> HashMap k' (P v)
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HashMap.fromList ([(k', P v)] -> HashMap k' (P v))
-> (HashMap k (P v) -> [(k', P v)])
-> HashMap k (P v)
-> HashMap k' (P v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((k, P v) -> (k', P v)) -> [(k, P v)] -> [(k', P v)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((k -> k') -> (k, P v) -> (k', P v)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first k -> k'
f) ([(k, P v)] -> [(k', P v)])
-> (HashMap k (P v) -> [(k, P v)])
-> HashMap k (P v)
-> [(k', P v)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashMap k (P v) -> [(k, P v)]
forall k v. HashMap k v -> [(k, v)]
HashMap.toList (HashMap k (P v) -> HashMap k' (P v))
-> HashMap k (P v) -> HashMap k' (P v)
forall a b. (a -> b) -> a -> b
$ HashMap k (P v)
m
traverseKeys
:: (Eq k', Hashable k', Applicative f)
=> (k -> f k') -> InsOrdHashMap k v -> f (InsOrdHashMap k' v)
traverseKeys :: (k -> f k') -> InsOrdHashMap k v -> f (InsOrdHashMap k' v)
traverseKeys k -> f k'
f (InsOrdHashMap Int
i HashMap k (P v)
m) = Int -> HashMap k' (P v) -> InsOrdHashMap k' v
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
i (HashMap k' (P v) -> InsOrdHashMap k' v)
-> ([(k', P v)] -> HashMap k' (P v))
-> [(k', P v)]
-> InsOrdHashMap k' v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(k', P v)] -> HashMap k' (P v)
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HashMap.fromList ([(k', P v)] -> InsOrdHashMap k' v)
-> f [(k', P v)] -> f (InsOrdHashMap k' v)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
(((k, P v) -> f (k', P v)) -> [(k, P v)] -> f [(k', P v)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (((k, P v) -> f (k', P v)) -> [(k, P v)] -> f [(k', P v)])
-> ((k -> f k') -> (k, P v) -> f (k', P v))
-> (k -> f k')
-> [(k, P v)]
-> f [(k', P v)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (k -> f k') -> (k, P v) -> f (k', P v)
forall s t a b. Field1 s t a b => Lens s t a b
_1) k -> f k'
f (HashMap k (P v) -> [(k, P v)]
forall k v. HashMap k v -> [(k, v)]
HashMap.toList HashMap k (P v)
m)
map :: (v1 -> v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2
map :: (v1 -> v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2
map = (v1 -> v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
mapWithKey :: (k -> v1 -> v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2
mapWithKey :: (k -> v1 -> v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2
mapWithKey k -> v1 -> v2
f (InsOrdHashMap Int
i HashMap k (P v1)
m) =
Int -> HashMap k (P v2) -> InsOrdHashMap k v2
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
i (HashMap k (P v2) -> InsOrdHashMap k v2)
-> HashMap k (P v2) -> InsOrdHashMap k v2
forall a b. (a -> b) -> a -> b
$ (k -> P v1 -> P v2) -> HashMap k (P v1) -> HashMap k (P v2)
forall k v1 v2. (k -> v1 -> v2) -> HashMap k v1 -> HashMap k v2
HashMap.mapWithKey k -> P v1 -> P v2
f' HashMap k (P v1)
m
where
f' :: k -> P v1 -> P v2
f' k
k (P Int
j v1
x) = Int -> v2 -> P v2
forall a. Int -> a -> P a
P Int
j (k -> v1 -> v2
f k
k v1
x)
foldMapWithKey :: Monoid m => (k -> a -> m) -> InsOrdHashMap k a -> m
foldMapWithKey :: (k -> a -> m) -> InsOrdHashMap k a -> m
foldMapWithKey k -> a -> m
f = ((k, a) -> m) -> [(k, a)] -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap ((k -> a -> m) -> (k, a) -> m
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry k -> a -> m
f) ([(k, a)] -> m)
-> (InsOrdHashMap k a -> [(k, a)]) -> InsOrdHashMap k a -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InsOrdHashMap k a -> [(k, a)]
forall k v. InsOrdHashMap k v -> [(k, v)]
toList
traverseWithKey :: Applicative f => (k -> a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
traverseWithKey :: (k -> a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
traverseWithKey k -> a -> f b
f (InsOrdHashMap Int
n HashMap k (P a)
m) = Int -> HashMap k (P b) -> InsOrdHashMap k b
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
n (HashMap k (P b) -> InsOrdHashMap k b)
-> f (HashMap k (P b)) -> f (InsOrdHashMap k b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SortedAp f (HashMap k (P b)) -> f (HashMap k (P b))
forall (f :: * -> *) a. Applicative f => SortedAp f a -> f a
retractSortedAp
((k -> P a -> SortedAp f (P b))
-> HashMap k (P a) -> SortedAp f (HashMap k (P b))
forall (f :: * -> *) k v1 v2.
Applicative f =>
(k -> v1 -> f v2) -> HashMap k v1 -> f (HashMap k v2)
HashMap.traverseWithKey (\k
k (P Int
i a
v) -> Int -> f (P b) -> SortedAp f (P b)
forall (f :: * -> *) a. Int -> f a -> SortedAp f a
liftSortedAp Int
i (Int -> b -> P b
forall a. Int -> a -> P a
P Int
i (b -> P b) -> f b -> f (P b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> k -> a -> f b
f k
k a
v)) HashMap k (P a)
m)
unorderedFoldMap :: Monoid m => (a -> m) -> InsOrdHashMap k a -> m
unorderedFoldMap :: (a -> m) -> InsOrdHashMap k a -> m
unorderedFoldMap a -> m
f (InsOrdHashMap Int
_ HashMap k (P a)
m) = (P a -> m) -> HashMap k (P a) -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (a -> m
f (a -> m) -> (P a -> a) -> P a -> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. P a -> a
forall a. P a -> a
getPV) HashMap k (P a)
m
unorderedFoldMapWithKey :: Monoid m => (k -> a -> m) -> InsOrdHashMap k a -> m
unorderedFoldMapWithKey :: (k -> a -> m) -> InsOrdHashMap k a -> m
unorderedFoldMapWithKey k -> a -> m
f InsOrdHashMap k a
m =
Const m (InsOrdHashMap k Any) -> m
forall a k (b :: k). Const a b -> a
getConst ((k -> a -> Const m Any)
-> InsOrdHashMap k a -> Const m (InsOrdHashMap k Any)
forall (f :: * -> *) k a b.
Applicative f =>
(k -> a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
unorderedTraverseWithKey (\k
k a
a -> m -> Const m Any
forall k a (b :: k). a -> Const a b
Const (k -> a -> m
f k
k a
a)) InsOrdHashMap k a
m)
unorderedTraverse :: Applicative f => (a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
unorderedTraverse :: (a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
unorderedTraverse a -> f b
f (InsOrdHashMap Int
i HashMap k (P a)
m) =
Int -> HashMap k (P b) -> InsOrdHashMap k b
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
i (HashMap k (P b) -> InsOrdHashMap k b)
-> f (HashMap k (P b)) -> f (InsOrdHashMap k b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((P a -> f (P b)) -> HashMap k (P a) -> f (HashMap k (P b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((P a -> f (P b)) -> HashMap k (P a) -> f (HashMap k (P b)))
-> ((a -> f b) -> P a -> f (P b))
-> (a -> f b)
-> HashMap k (P a)
-> f (HashMap k (P b))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> f b) -> P a -> f (P b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse) a -> f b
f HashMap k (P a)
m
unorderedTraverseWithKey :: Applicative f => (k -> a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
unorderedTraverseWithKey :: (k -> a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
unorderedTraverseWithKey k -> a -> f b
f (InsOrdHashMap Int
i HashMap k (P a)
m) =
Int -> HashMap k (P b) -> InsOrdHashMap k b
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
i (HashMap k (P b) -> InsOrdHashMap k b)
-> f (HashMap k (P b)) -> f (InsOrdHashMap k b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (k -> P a -> f (P b)) -> HashMap k (P a) -> f (HashMap k (P b))
forall (f :: * -> *) k v1 v2.
Applicative f =>
(k -> v1 -> f v2) -> HashMap k v1 -> f (HashMap k v2)
HashMap.traverseWithKey k -> P a -> f (P b)
f' HashMap k (P a)
m
where
f' :: k -> P a -> f (P b)
f' k
k (P Int
j a
x) = Int -> b -> P b
forall a. Int -> a -> P a
P Int
j (b -> P b) -> f b -> f (P b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> k -> a -> f b
f k
k a
x
difference
:: (Eq k, Hashable k)
=> InsOrdHashMap k v -> InsOrdHashMap k w -> InsOrdHashMap k v
difference :: InsOrdHashMap k v -> InsOrdHashMap k w -> InsOrdHashMap k v
difference (InsOrdHashMap Int
i HashMap k (P v)
a) (InsOrdHashMap Int
_ HashMap k (P w)
b) =
Int -> HashMap k (P v) -> InsOrdHashMap k v
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
i (HashMap k (P v) -> InsOrdHashMap k v)
-> HashMap k (P v) -> InsOrdHashMap k v
forall a b. (a -> b) -> a -> b
$ HashMap k (P v) -> HashMap k (P w) -> HashMap k (P v)
forall k v w.
(Eq k, Hashable k) =>
HashMap k v -> HashMap k w -> HashMap k v
HashMap.difference HashMap k (P v)
a HashMap k (P w)
b
intersection
:: (Eq k, Hashable k)
=> InsOrdHashMap k v -> InsOrdHashMap k w -> InsOrdHashMap k v
intersection :: InsOrdHashMap k v -> InsOrdHashMap k w -> InsOrdHashMap k v
intersection = (v -> w -> v)
-> InsOrdHashMap k v -> InsOrdHashMap k w -> InsOrdHashMap k v
forall k v1 v2 v3.
(Eq k, Hashable k) =>
(v1 -> v2 -> v3)
-> InsOrdHashMap k v1 -> InsOrdHashMap k v2 -> InsOrdHashMap k v3
intersectionWith v -> w -> v
forall a b. a -> b -> a
const
intersectionWith
:: (Eq k, Hashable k)
=> (v1 -> v2 -> v3)
-> InsOrdHashMap k v1 -> InsOrdHashMap k v2 -> InsOrdHashMap k v3
intersectionWith :: (v1 -> v2 -> v3)
-> InsOrdHashMap k v1 -> InsOrdHashMap k v2 -> InsOrdHashMap k v3
intersectionWith v1 -> v2 -> v3
f = (k -> v1 -> v2 -> v3)
-> InsOrdHashMap k v1 -> InsOrdHashMap k v2 -> InsOrdHashMap k v3
forall k v1 v2 v3.
(Eq k, Hashable k) =>
(k -> v1 -> v2 -> v3)
-> InsOrdHashMap k v1 -> InsOrdHashMap k v2 -> InsOrdHashMap k v3
intersectionWithKey (\k
_ -> v1 -> v2 -> v3
f)
intersectionWithKey
:: (Eq k, Hashable k)
=> (k -> v1 -> v2 -> v3)
-> InsOrdHashMap k v1 -> InsOrdHashMap k v2 -> InsOrdHashMap k v3
intersectionWithKey :: (k -> v1 -> v2 -> v3)
-> InsOrdHashMap k v1 -> InsOrdHashMap k v2 -> InsOrdHashMap k v3
intersectionWithKey k -> v1 -> v2 -> v3
f (InsOrdHashMap Int
i HashMap k (P v1)
a) (InsOrdHashMap Int
_ HashMap k (P v2)
b) =
Int -> HashMap k (P v3) -> InsOrdHashMap k v3
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
i (HashMap k (P v3) -> InsOrdHashMap k v3)
-> HashMap k (P v3) -> InsOrdHashMap k v3
forall a b. (a -> b) -> a -> b
$ (k -> P v1 -> P v2 -> P v3)
-> HashMap k (P v1) -> HashMap k (P v2) -> HashMap k (P v3)
forall k v1 v2 v3.
(Eq k, Hashable k) =>
(k -> v1 -> v2 -> v3)
-> HashMap k v1 -> HashMap k v2 -> HashMap k v3
HashMap.intersectionWithKey k -> P v1 -> P v2 -> P v3
f' HashMap k (P v1)
a HashMap k (P v2)
b
where
f' :: k -> P v1 -> P v2 -> P v3
f' k
k (P Int
j v1
x) (P Int
_ v2
y) = Int -> v3 -> P v3
forall a. Int -> a -> P a
P Int
j (k -> v1 -> v2 -> v3
f k
k v1
x v2
y)
foldl' :: (a -> v -> a) -> a -> InsOrdHashMap k v -> a
foldl' :: (a -> v -> a) -> a -> InsOrdHashMap k v -> a
foldl' a -> v -> a
f a
x = (a -> (k, v) -> a) -> a -> [(k, v)] -> a
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
F.foldl' a -> (k, v) -> a
f' a
x ([(k, v)] -> a)
-> (InsOrdHashMap k v -> [(k, v)]) -> InsOrdHashMap k v -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InsOrdHashMap k v -> [(k, v)]
forall k v. InsOrdHashMap k v -> [(k, v)]
toList
where
f' :: a -> (k, v) -> a
f' a
a (k
_, v
v) = a -> v -> a
f a
a v
v
foldlWithKey' :: (a -> k -> v -> a) -> a -> InsOrdHashMap k v -> a
foldlWithKey' :: (a -> k -> v -> a) -> a -> InsOrdHashMap k v -> a
foldlWithKey' a -> k -> v -> a
f a
x = (a -> (k, v) -> a) -> a -> [(k, v)] -> a
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
F.foldl' a -> (k, v) -> a
f' a
x ([(k, v)] -> a)
-> (InsOrdHashMap k v -> [(k, v)]) -> InsOrdHashMap k v -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InsOrdHashMap k v -> [(k, v)]
forall k v. InsOrdHashMap k v -> [(k, v)]
toList
where
f' :: a -> (k, v) -> a
f' a
a (k
k, v
v) = a -> k -> v -> a
f a
a k
k v
v
foldr :: (v -> a -> a) -> a -> InsOrdHashMap k v -> a
foldr :: (v -> a -> a) -> a -> InsOrdHashMap k v -> a
foldr v -> a -> a
f a
x = ((k, v) -> a -> a) -> a -> [(k, v)] -> a
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
F.foldr (k, v) -> a -> a
f' a
x ([(k, v)] -> a)
-> (InsOrdHashMap k v -> [(k, v)]) -> InsOrdHashMap k v -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InsOrdHashMap k v -> [(k, v)]
forall k v. InsOrdHashMap k v -> [(k, v)]
toList
where
f' :: (k, v) -> a -> a
f' (k
_, v
v) a
a = v -> a -> a
f v
v a
a
foldrWithKey :: (k -> v -> a -> a) -> a -> InsOrdHashMap k v -> a
foldrWithKey :: (k -> v -> a -> a) -> a -> InsOrdHashMap k v -> a
foldrWithKey k -> v -> a -> a
f a
x = ((k, v) -> a -> a) -> a -> [(k, v)] -> a
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
F.foldr (k, v) -> a -> a
f' a
x ([(k, v)] -> a)
-> (InsOrdHashMap k v -> [(k, v)]) -> InsOrdHashMap k v -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InsOrdHashMap k v -> [(k, v)]
forall k v. InsOrdHashMap k v -> [(k, v)]
toList
where
f' :: (k, v) -> a -> a
f' (k
k, v
v) a
a = k -> v -> a -> a
f k
k v
v a
a
filter :: (v -> Bool) -> InsOrdHashMap k v -> InsOrdHashMap k v
filter :: (v -> Bool) -> InsOrdHashMap k v -> InsOrdHashMap k v
filter v -> Bool
f (InsOrdHashMap Int
i HashMap k (P v)
m) =
Int -> HashMap k (P v) -> InsOrdHashMap k v
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
i (HashMap k (P v) -> InsOrdHashMap k v)
-> HashMap k (P v) -> InsOrdHashMap k v
forall a b. (a -> b) -> a -> b
$ (P v -> Bool) -> HashMap k (P v) -> HashMap k (P v)
forall v k. (v -> Bool) -> HashMap k v -> HashMap k v
HashMap.filter (v -> Bool
f (v -> Bool) -> (P v -> v) -> P v -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. P v -> v
forall a. P a -> a
getPV) HashMap k (P v)
m
filterWithKey :: (k -> v -> Bool) -> InsOrdHashMap k v -> InsOrdHashMap k v
filterWithKey :: (k -> v -> Bool) -> InsOrdHashMap k v -> InsOrdHashMap k v
filterWithKey k -> v -> Bool
f (InsOrdHashMap Int
i HashMap k (P v)
m) =
Int -> HashMap k (P v) -> InsOrdHashMap k v
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
i (HashMap k (P v) -> InsOrdHashMap k v)
-> HashMap k (P v) -> InsOrdHashMap k v
forall a b. (a -> b) -> a -> b
$ (k -> P v -> Bool) -> HashMap k (P v) -> HashMap k (P v)
forall k v. (k -> v -> Bool) -> HashMap k v -> HashMap k v
HashMap.filterWithKey k -> P v -> Bool
f' HashMap k (P v)
m
where
f' :: k -> P v -> Bool
f' k
k (P Int
_ v
x) = k -> v -> Bool
f k
k v
x
mapMaybe :: (v1 -> Maybe v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2
mapMaybe :: (v1 -> Maybe v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2
mapMaybe v1 -> Maybe v2
f (InsOrdHashMap Int
i HashMap k (P v1)
m) = Int -> HashMap k (P v2) -> InsOrdHashMap k v2
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
i (HashMap k (P v2) -> InsOrdHashMap k v2)
-> HashMap k (P v2) -> InsOrdHashMap k v2
forall a b. (a -> b) -> a -> b
$ (P v1 -> Maybe (P v2)) -> HashMap k (P v1) -> HashMap k (P v2)
forall v1 v2 k. (v1 -> Maybe v2) -> HashMap k v1 -> HashMap k v2
HashMap.mapMaybe P v1 -> Maybe (P v2)
f' HashMap k (P v1)
m
where
f' :: P v1 -> Maybe (P v2)
f' (P Int
j v1
x) = Int -> v2 -> P v2
forall a. Int -> a -> P a
P Int
j (v2 -> P v2) -> Maybe v2 -> Maybe (P v2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> v1 -> Maybe v2
f v1
x
mapMaybeWithKey :: (k -> v1 -> Maybe v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2
mapMaybeWithKey :: (k -> v1 -> Maybe v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2
mapMaybeWithKey k -> v1 -> Maybe v2
f (InsOrdHashMap Int
i HashMap k (P v1)
m) =
Int -> HashMap k (P v2) -> InsOrdHashMap k v2
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
i (HashMap k (P v2) -> InsOrdHashMap k v2)
-> HashMap k (P v2) -> InsOrdHashMap k v2
forall a b. (a -> b) -> a -> b
$ (k -> P v1 -> Maybe (P v2)) -> HashMap k (P v1) -> HashMap k (P v2)
forall k v1 v2.
(k -> v1 -> Maybe v2) -> HashMap k v1 -> HashMap k v2
HashMap.mapMaybeWithKey k -> P v1 -> Maybe (P v2)
f' HashMap k (P v1)
m
where
f' :: k -> P v1 -> Maybe (P v2)
f' k
k (P Int
j v1
x) = Int -> v2 -> P v2
forall a. Int -> a -> P a
P Int
j (v2 -> P v2) -> Maybe v2 -> Maybe (P v2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> k -> v1 -> Maybe v2
f k
k v1
x
keys :: InsOrdHashMap k v -> [k]
keys :: InsOrdHashMap k v -> [k]
keys = ((k, v) -> k) -> [(k, v)] -> [k]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (k, v) -> k
forall a b. (a, b) -> a
fst ([(k, v)] -> [k])
-> (InsOrdHashMap k v -> [(k, v)]) -> InsOrdHashMap k v -> [k]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InsOrdHashMap k v -> [(k, v)]
forall k v. InsOrdHashMap k v -> [(k, v)]
toList
{-# INLINABLE keys #-}
elems :: InsOrdHashMap k v -> [v]
elems :: InsOrdHashMap k v -> [v]
elems = ((k, v) -> v) -> [(k, v)] -> [v]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (k, v) -> v
forall a b. (a, b) -> b
snd ([(k, v)] -> [v])
-> (InsOrdHashMap k v -> [(k, v)]) -> InsOrdHashMap k v -> [v]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InsOrdHashMap k v -> [(k, v)]
forall k v. InsOrdHashMap k v -> [(k, v)]
toList
{-# INLINABLE elems #-}
fromList :: forall k v. (Eq k, Hashable k) => [(k, v)] -> InsOrdHashMap k v
fromList :: [(k, v)] -> InsOrdHashMap k v
fromList
= ([(k, P v)], Int) -> InsOrdHashMap k v
mk
(([(k, P v)], Int) -> InsOrdHashMap k v)
-> ([(k, v)] -> ([(k, P v)], Int)) -> [(k, v)] -> InsOrdHashMap k v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (State Int [(k, P v)] -> Int -> ([(k, P v)], Int))
-> Int -> State Int [(k, P v)] -> ([(k, P v)], Int)
forall a b c. (a -> b -> c) -> b -> a -> c
flip State Int [(k, P v)] -> Int -> ([(k, P v)], Int)
forall s a. State s a -> s -> (a, s)
runState Int
0
(State Int [(k, P v)] -> ([(k, P v)], Int))
-> ([(k, v)] -> State Int [(k, P v)])
-> [(k, v)]
-> ([(k, P v)], Int)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (((k, v) -> StateT Int Identity (k, P v))
-> [(k, v)] -> State Int [(k, P v)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (((k, v) -> StateT Int Identity (k, P v))
-> [(k, v)] -> State Int [(k, P v)])
-> ((v -> StateT Int Identity (P v))
-> (k, v) -> StateT Int Identity (k, P v))
-> (v -> StateT Int Identity (P v))
-> [(k, v)]
-> State Int [(k, P v)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (v -> StateT Int Identity (P v))
-> (k, v) -> StateT Int Identity (k, P v)
forall s t a b. Field2 s t a b => Lens s t a b
_2) v -> StateT Int Identity (P v)
forall a. a -> State Int (P a)
newP
where
mk :: ([(k, P v)], Int) -> InsOrdHashMap k v
mk :: ([(k, P v)], Int) -> InsOrdHashMap k v
mk ([(k, P v)]
m, Int
i) = Int -> HashMap k (P v) -> InsOrdHashMap k v
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
i ([(k, P v)] -> HashMap k (P v)
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HashMap.fromList [(k, P v)]
m)
toList :: InsOrdHashMap k v -> [(k, v)]
toList :: InsOrdHashMap k v -> [(k, v)]
toList
= ((k, P v) -> (k, v)) -> [(k, P v)] -> [(k, v)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((P v -> v) -> (k, P v) -> (k, v)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second P v -> v
forall a. P a -> a
getPV)
([(k, P v)] -> [(k, v)])
-> (InsOrdHashMap k v -> [(k, P v)])
-> InsOrdHashMap k v
-> [(k, v)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((k, P v) -> (k, P v) -> Ordering) -> [(k, P v)] -> [(k, P v)]
forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (((k, P v) -> Int) -> (k, P v) -> (k, P v) -> Ordering
forall a b. Ord a => (b -> a) -> b -> b -> Ordering
comparing (P v -> Int
forall a. P a -> Int
getPK (P v -> Int) -> ((k, P v) -> P v) -> (k, P v) -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (k, P v) -> P v
forall a b. (a, b) -> b
snd))
([(k, P v)] -> [(k, P v)])
-> (InsOrdHashMap k v -> [(k, P v)])
-> InsOrdHashMap k v
-> [(k, P v)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashMap k (P v) -> [(k, P v)]
forall k v. HashMap k v -> [(k, v)]
HashMap.toList
(HashMap k (P v) -> [(k, P v)])
-> (InsOrdHashMap k v -> HashMap k (P v))
-> InsOrdHashMap k v
-> [(k, P v)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InsOrdHashMap k v -> HashMap k (P v)
forall k v. InsOrdHashMap k v -> HashMap k (P v)
getInsOrdHashMap
toRevList :: InsOrdHashMap k v -> [(k, v)]
toRevList :: InsOrdHashMap k v -> [(k, v)]
toRevList
= ((k, P v) -> (k, v)) -> [(k, P v)] -> [(k, v)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((P v -> v) -> (k, P v) -> (k, v)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second P v -> v
forall a. P a -> a
getPV)
([(k, P v)] -> [(k, v)])
-> (InsOrdHashMap k v -> [(k, P v)])
-> InsOrdHashMap k v
-> [(k, v)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((k, P v) -> (k, P v) -> Ordering) -> [(k, P v)] -> [(k, P v)]
forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (((k, P v) -> (k, P v) -> Ordering)
-> (k, P v) -> (k, P v) -> Ordering
forall a b c. (a -> b -> c) -> b -> a -> c
flip (((k, P v) -> (k, P v) -> Ordering)
-> (k, P v) -> (k, P v) -> Ordering)
-> ((k, P v) -> (k, P v) -> Ordering)
-> (k, P v)
-> (k, P v)
-> Ordering
forall a b. (a -> b) -> a -> b
$ ((k, P v) -> Int) -> (k, P v) -> (k, P v) -> Ordering
forall a b. Ord a => (b -> a) -> b -> b -> Ordering
comparing (P v -> Int
forall a. P a -> Int
getPK (P v -> Int) -> ((k, P v) -> P v) -> (k, P v) -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (k, P v) -> P v
forall a b. (a, b) -> b
snd))
([(k, P v)] -> [(k, P v)])
-> (InsOrdHashMap k v -> [(k, P v)])
-> InsOrdHashMap k v
-> [(k, P v)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashMap k (P v) -> [(k, P v)]
forall k v. HashMap k v -> [(k, v)]
HashMap.toList
(HashMap k (P v) -> [(k, P v)])
-> (InsOrdHashMap k v -> HashMap k (P v))
-> InsOrdHashMap k v
-> [(k, P v)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InsOrdHashMap k v -> HashMap k (P v)
forall k v. InsOrdHashMap k v -> HashMap k (P v)
getInsOrdHashMap
fromHashMap :: HashMap k v -> InsOrdHashMap k v
fromHashMap :: HashMap k v -> InsOrdHashMap k v
fromHashMap = (HashMap k (P v), Int) -> InsOrdHashMap k v
forall k v. (HashMap k (P v), Int) -> InsOrdHashMap k v
mk ((HashMap k (P v), Int) -> InsOrdHashMap k v)
-> (HashMap k v -> (HashMap k (P v), Int))
-> HashMap k v
-> InsOrdHashMap k v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (State Int (HashMap k (P v)) -> Int -> (HashMap k (P v), Int))
-> Int -> State Int (HashMap k (P v)) -> (HashMap k (P v), Int)
forall a b c. (a -> b -> c) -> b -> a -> c
flip State Int (HashMap k (P v)) -> Int -> (HashMap k (P v), Int)
forall s a. State s a -> s -> (a, s)
runState Int
0 (State Int (HashMap k (P v)) -> (HashMap k (P v), Int))
-> (HashMap k v -> State Int (HashMap k (P v)))
-> HashMap k v
-> (HashMap k (P v), Int)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (v -> StateT Int Identity (P v))
-> HashMap k v -> State Int (HashMap k (P v))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse v -> StateT Int Identity (P v)
forall a. a -> State Int (P a)
newP
where
mk :: (HashMap k (P v), Int) -> InsOrdHashMap k v
mk (HashMap k (P v)
m, Int
i) = Int -> HashMap k (P v) -> InsOrdHashMap k v
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
i HashMap k (P v)
m
toHashMap :: InsOrdHashMap k v -> HashMap k v
toHashMap :: InsOrdHashMap k v -> HashMap k v
toHashMap (InsOrdHashMap Int
_ HashMap k (P v)
m) = (P v -> v) -> HashMap k (P v) -> HashMap k v
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap P v -> v
forall a. P a -> a
getPV HashMap k (P v)
m
fromHashMapP :: HashMap k (P v) -> InsOrdHashMap k v
fromHashMapP :: HashMap k (P v) -> InsOrdHashMap k v
fromHashMapP = (HashMap k (P v), Int) -> InsOrdHashMap k v
forall k v. (HashMap k (P v), Int) -> InsOrdHashMap k v
mk ((HashMap k (P v), Int) -> InsOrdHashMap k v)
-> (HashMap k (P v) -> (HashMap k (P v), Int))
-> HashMap k (P v)
-> InsOrdHashMap k v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (State Int (HashMap k (P v)) -> Int -> (HashMap k (P v), Int))
-> Int -> State Int (HashMap k (P v)) -> (HashMap k (P v), Int)
forall a b c. (a -> b -> c) -> b -> a -> c
flip State Int (HashMap k (P v)) -> Int -> (HashMap k (P v), Int)
forall s a. State s a -> s -> (a, s)
runState Int
0 (State Int (HashMap k (P v)) -> (HashMap k (P v), Int))
-> (HashMap k (P v) -> State Int (HashMap k (P v)))
-> HashMap k (P v)
-> (HashMap k (P v), Int)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SortedAp (StateT Int Identity) (HashMap k (P v))
-> State Int (HashMap k (P v))
forall (f :: * -> *) a. Applicative f => SortedAp f a -> f a
retractSortedAp (SortedAp (StateT Int Identity) (HashMap k (P v))
-> State Int (HashMap k (P v)))
-> (HashMap k (P v)
-> SortedAp (StateT Int Identity) (HashMap k (P v)))
-> HashMap k (P v)
-> State Int (HashMap k (P v))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (P v -> SortedAp (StateT Int Identity) (P v))
-> HashMap k (P v)
-> SortedAp (StateT Int Identity) (HashMap k (P v))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse P v -> SortedAp (StateT Int Identity) (P v)
forall a. P a -> SortedAp (StateT Int Identity) (P a)
f
where
mk :: (HashMap k (P v), Int) -> InsOrdHashMap k v
mk (HashMap k (P v)
m, Int
i) = Int -> HashMap k (P v) -> InsOrdHashMap k v
forall k v. Int -> HashMap k (P v) -> InsOrdHashMap k v
InsOrdHashMap Int
i HashMap k (P v)
m
f :: P a -> SortedAp (StateT Int Identity) (P a)
f (P Int
i a
v) = Int
-> StateT Int Identity (P a)
-> SortedAp (StateT Int Identity) (P a)
forall (f :: * -> *) a. Int -> f a -> SortedAp f a
liftSortedAp Int
i (a -> StateT Int Identity (P a)
forall a. a -> State Int (P a)
newP a
v)
valid :: InsOrdHashMap k v -> Bool
valid :: InsOrdHashMap k v -> Bool
valid (InsOrdHashMap Int
i HashMap k (P v)
m) = Bool
indexesDistinct Bool -> Bool -> Bool
&& Bool
indexesSmaller
where
indexes :: [Int]
indexes :: [Int]
indexes = P v -> Int
forall a. P a -> Int
getPK (P v -> Int) -> [P v] -> [Int]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HashMap k (P v) -> [P v]
forall k v. HashMap k v -> [v]
HashMap.elems HashMap k (P v)
m
indexesDistinct :: Bool
indexesDistinct = [Int]
indexes [Int] -> [Int] -> Bool
forall a. Eq a => a -> a -> Bool
== [Int] -> [Int]
forall a. Eq a => [a] -> [a]
nub [Int]
indexes
indexesSmaller :: Bool
indexesSmaller = (Int -> Bool) -> [Int] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
i) [Int]
indexes
newP :: a -> State Int (P a)
newP :: a -> State Int (P a)
newP a
x = (Int -> (P a, Int)) -> State Int (P a)
forall (m :: * -> *) s a. Monad m => (s -> (a, s)) -> StateT s m a
state ((Int -> (P a, Int)) -> State Int (P a))
-> (Int -> (P a, Int)) -> State Int (P a)
forall a b. (a -> b) -> a -> b
$ \Int
s -> (Int -> a -> P a
forall a. Int -> a -> P a
P Int
s a
x, Int
s Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)