{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveLift #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE StrictData #-}
module OpenTelemetry.Attributes (
Attributes,
emptyAttributes,
addAttribute,
addAttributeByKey,
addAttributes,
lookupAttribute,
lookupAttributeByKey,
getAttributeMap,
getCount,
getDropped,
Attribute (..),
ToAttribute (..),
FromAttribute (..),
PrimitiveAttribute (..),
ToPrimitiveAttribute (..),
FromPrimitiveAttribute (..),
Map.AttributeMap,
AttributeKey (..),
module Key,
AttributeLimits (..),
defaultAttributeLimits,
unsafeAttributesFromListIgnoringLimits,
unsafeMergeAttributesIgnoringLimits,
) where
import Data.Data (Data)
import qualified Data.HashMap.Strict as H
import Data.Hashable (Hashable)
import Data.Text (Text)
import qualified Data.Text as T
import GHC.Generics (Generic)
import qualified Language.Haskell.TH.Syntax as TH
import OpenTelemetry.Attributes.Attribute (Attribute (..), FromAttribute (..), FromPrimitiveAttribute (..), PrimitiveAttribute (..), ToAttribute (..), ToPrimitiveAttribute (..))
import OpenTelemetry.Attributes.Key as Key
import qualified OpenTelemetry.Attributes.Map as Map
defaultAttributeLimits :: AttributeLimits
defaultAttributeLimits :: AttributeLimits
defaultAttributeLimits =
AttributeLimits
{ attributeCountLimit :: Maybe Int
attributeCountLimit = Int -> Maybe Int
forall a. a -> Maybe a
Just Int
128
, attributeLengthLimit :: Maybe Int
attributeLengthLimit = Maybe Int
forall a. Maybe a
Nothing
}
data Attributes = Attributes
{ Attributes -> AttributeMap
attributeMap :: !Map.AttributeMap
, Attributes -> Int
attributesCount :: {-# UNPACK #-} !Int
, Attributes -> Int
attributesDropped :: {-# UNPACK #-} !Int
}
deriving stock (Int -> Attributes -> ShowS
[Attributes] -> ShowS
Attributes -> String
(Int -> Attributes -> ShowS)
-> (Attributes -> String)
-> ([Attributes] -> ShowS)
-> Show Attributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Attributes -> ShowS
showsPrec :: Int -> Attributes -> ShowS
$cshow :: Attributes -> String
show :: Attributes -> String
$cshowList :: [Attributes] -> ShowS
showList :: [Attributes] -> ShowS
Show, (forall x. Attributes -> Rep Attributes x)
-> (forall x. Rep Attributes x -> Attributes) -> Generic Attributes
forall x. Rep Attributes x -> Attributes
forall x. Attributes -> Rep Attributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Attributes -> Rep Attributes x
from :: forall x. Attributes -> Rep Attributes x
$cto :: forall x. Rep Attributes x -> Attributes
to :: forall x. Rep Attributes x -> Attributes
Generic, Attributes -> Attributes -> Bool
(Attributes -> Attributes -> Bool)
-> (Attributes -> Attributes -> Bool) -> Eq Attributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Attributes -> Attributes -> Bool
== :: Attributes -> Attributes -> Bool
$c/= :: Attributes -> Attributes -> Bool
/= :: Attributes -> Attributes -> Bool
Eq, Eq Attributes
Eq Attributes =>
(Attributes -> Attributes -> Ordering)
-> (Attributes -> Attributes -> Bool)
-> (Attributes -> Attributes -> Bool)
-> (Attributes -> Attributes -> Bool)
-> (Attributes -> Attributes -> Bool)
-> (Attributes -> Attributes -> Attributes)
-> (Attributes -> Attributes -> Attributes)
-> Ord Attributes
Attributes -> Attributes -> Bool
Attributes -> Attributes -> Ordering
Attributes -> Attributes -> Attributes
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
$ccompare :: Attributes -> Attributes -> Ordering
compare :: Attributes -> Attributes -> Ordering
$c< :: Attributes -> Attributes -> Bool
< :: Attributes -> Attributes -> Bool
$c<= :: Attributes -> Attributes -> Bool
<= :: Attributes -> Attributes -> Bool
$c> :: Attributes -> Attributes -> Bool
> :: Attributes -> Attributes -> Bool
$c>= :: Attributes -> Attributes -> Bool
>= :: Attributes -> Attributes -> Bool
$cmax :: Attributes -> Attributes -> Attributes
max :: Attributes -> Attributes -> Attributes
$cmin :: Attributes -> Attributes -> Attributes
min :: Attributes -> Attributes -> Attributes
Ord, (forall (m :: * -> *). Quote m => Attributes -> m Exp)
-> (forall (m :: * -> *).
Quote m =>
Attributes -> Code m Attributes)
-> Lift Attributes
forall t.
(forall (m :: * -> *). Quote m => t -> m Exp)
-> (forall (m :: * -> *). Quote m => t -> Code m t) -> Lift t
forall (m :: * -> *). Quote m => Attributes -> m Exp
forall (m :: * -> *). Quote m => Attributes -> Code m Attributes
$clift :: forall (m :: * -> *). Quote m => Attributes -> m Exp
lift :: forall (m :: * -> *). Quote m => Attributes -> m Exp
$cliftTyped :: forall (m :: * -> *). Quote m => Attributes -> Code m Attributes
liftTyped :: forall (m :: * -> *). Quote m => Attributes -> Code m Attributes
TH.Lift)
instance Hashable Attributes
emptyAttributes :: Attributes
emptyAttributes :: Attributes
emptyAttributes = AttributeMap -> Int -> Int -> Attributes
Attributes AttributeMap
forall a. Monoid a => a
mempty Int
0 Int
0
addAttribute :: (ToAttribute a) => AttributeLimits -> Attributes -> Text -> a -> Attributes
addAttribute :: forall a.
ToAttribute a =>
AttributeLimits -> Attributes -> Text -> a -> Attributes
addAttribute AttributeLimits {Maybe Int
attributeCountLimit :: AttributeLimits -> Maybe Int
attributeLengthLimit :: AttributeLimits -> Maybe Int
attributeCountLimit :: Maybe Int
attributeLengthLimit :: Maybe Int
..} Attributes {Int
AttributeMap
attributeMap :: Attributes -> AttributeMap
attributesCount :: Attributes -> Int
attributesDropped :: Attributes -> Int
attributeMap :: AttributeMap
attributesCount :: Int
attributesDropped :: Int
..} !Text
k !a
v = case Maybe Int
attributeCountLimit of
Maybe Int
Nothing -> AttributeMap -> Int -> Int -> Attributes
Attributes AttributeMap
newAttrs Int
newCount Int
attributesDropped
Just Int
limit_ ->
if Int
newCount Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
limit_
then AttributeMap -> Int -> Int -> Attributes
Attributes AttributeMap
attributeMap Int
attributesCount (Int
attributesDropped Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
else AttributeMap -> Int -> Int -> Attributes
Attributes AttributeMap
newAttrs Int
newCount Int
attributesDropped
where
newAttrs :: AttributeMap
newAttrs = Text -> Attribute -> AttributeMap -> AttributeMap
forall k v.
(Eq k, Hashable k) =>
k -> v -> HashMap k v -> HashMap k v
H.insert Text
k ((Attribute -> Attribute)
-> (Int -> Attribute -> Attribute)
-> Maybe Int
-> Attribute
-> Attribute
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Attribute -> Attribute
forall a. a -> a
id Int -> Attribute -> Attribute
limitLengths Maybe Int
attributeLengthLimit (Attribute -> Attribute) -> Attribute -> Attribute
forall a b. (a -> b) -> a -> b
$ a -> Attribute
forall a. ToAttribute a => a -> Attribute
toAttribute a
v) AttributeMap
attributeMap
newCount :: Int
newCount = AttributeMap -> Int
forall k v. HashMap k v -> Int
H.size AttributeMap
newAttrs
{-# INLINE addAttribute #-}
addAttributeByKey :: (ToAttribute a) => AttributeLimits -> Attributes -> AttributeKey a -> a -> Attributes
addAttributeByKey :: forall a.
ToAttribute a =>
AttributeLimits -> Attributes -> AttributeKey a -> a -> Attributes
addAttributeByKey AttributeLimits
limits Attributes
attrs (AttributeKey Text
k) !a
v = AttributeLimits -> Attributes -> Text -> a -> Attributes
forall a.
ToAttribute a =>
AttributeLimits -> Attributes -> Text -> a -> Attributes
addAttribute AttributeLimits
limits Attributes
attrs Text
k a
v
addAttributes :: (ToAttribute a) => AttributeLimits -> Attributes -> H.HashMap Text a -> Attributes
addAttributes :: forall a.
ToAttribute a =>
AttributeLimits -> Attributes -> HashMap Text a -> Attributes
addAttributes AttributeLimits {Maybe Int
attributeCountLimit :: AttributeLimits -> Maybe Int
attributeLengthLimit :: AttributeLimits -> Maybe Int
attributeCountLimit :: Maybe Int
attributeLengthLimit :: Maybe Int
..} Attributes {Int
AttributeMap
attributeMap :: Attributes -> AttributeMap
attributesCount :: Attributes -> Int
attributesDropped :: Attributes -> Int
attributeMap :: AttributeMap
attributesCount :: Int
attributesDropped :: Int
..} HashMap Text a
attrs = case Maybe Int
attributeCountLimit of
Maybe Int
Nothing -> AttributeMap -> Int -> Int -> Attributes
Attributes AttributeMap
newAttrs Int
newCount Int
attributesDropped
Just Int
limit_ ->
if Int
newCount Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
limit_
then AttributeMap -> Int -> Int -> Attributes
Attributes AttributeMap
attributeMap Int
attributesCount (Int
attributesDropped Int -> Int -> Int
forall a. Num a => a -> a -> a
+ HashMap Text a -> Int
forall k v. HashMap k v -> Int
H.size HashMap Text a
attrs)
else AttributeMap -> Int -> Int -> Attributes
Attributes AttributeMap
newAttrs Int
newCount Int
attributesDropped
where
newAttrs :: AttributeMap
newAttrs = AttributeMap -> AttributeMap -> AttributeMap
forall k v. Eq k => HashMap k v -> HashMap k v -> HashMap k v
H.union AttributeMap
attributeMap (AttributeMap -> AttributeMap) -> AttributeMap -> AttributeMap
forall a b. (a -> b) -> a -> b
$ (a -> Attribute) -> HashMap Text a -> AttributeMap
forall v1 v2 k. (v1 -> v2) -> HashMap k v1 -> HashMap k v2
H.map ((Attribute -> Attribute)
-> (Int -> Attribute -> Attribute)
-> Maybe Int
-> Attribute
-> Attribute
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Attribute -> Attribute
forall a. a -> a
id Int -> Attribute -> Attribute
limitLengths Maybe Int
attributeLengthLimit (Attribute -> Attribute) -> (a -> Attribute) -> a -> Attribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Attribute
forall a. ToAttribute a => a -> Attribute
toAttribute) HashMap Text a
attrs
newCount :: Int
newCount = AttributeMap -> Int
forall k v. HashMap k v -> Int
H.size AttributeMap
newAttrs
{-# INLINE addAttributes #-}
limitPrimAttr :: Int -> PrimitiveAttribute -> PrimitiveAttribute
limitPrimAttr :: Int -> PrimitiveAttribute -> PrimitiveAttribute
limitPrimAttr Int
limit (TextAttribute Text
t) = Text -> PrimitiveAttribute
TextAttribute (Int -> Text -> Text
T.take Int
limit Text
t)
limitPrimAttr Int
_ PrimitiveAttribute
attr = PrimitiveAttribute
attr
limitLengths :: Int -> Attribute -> Attribute
limitLengths :: Int -> Attribute -> Attribute
limitLengths Int
limit (AttributeValue PrimitiveAttribute
val) = PrimitiveAttribute -> Attribute
AttributeValue (PrimitiveAttribute -> Attribute)
-> PrimitiveAttribute -> Attribute
forall a b. (a -> b) -> a -> b
$ Int -> PrimitiveAttribute -> PrimitiveAttribute
limitPrimAttr Int
limit PrimitiveAttribute
val
limitLengths Int
limit (AttributeArray [PrimitiveAttribute]
arr) = [PrimitiveAttribute] -> Attribute
AttributeArray ([PrimitiveAttribute] -> Attribute)
-> [PrimitiveAttribute] -> Attribute
forall a b. (a -> b) -> a -> b
$ (PrimitiveAttribute -> PrimitiveAttribute)
-> [PrimitiveAttribute] -> [PrimitiveAttribute]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Int -> PrimitiveAttribute -> PrimitiveAttribute
limitPrimAttr Int
limit) [PrimitiveAttribute]
arr
getAttributeMap :: Attributes -> Map.AttributeMap
getAttributeMap :: Attributes -> AttributeMap
getAttributeMap Attributes {Int
AttributeMap
attributeMap :: Attributes -> AttributeMap
attributesCount :: Attributes -> Int
attributesDropped :: Attributes -> Int
attributeMap :: AttributeMap
attributesCount :: Int
attributesDropped :: Int
..} = AttributeMap
attributeMap
getCount :: Attributes -> Int
getCount :: Attributes -> Int
getCount Attributes {Int
AttributeMap
attributeMap :: Attributes -> AttributeMap
attributesCount :: Attributes -> Int
attributesDropped :: Attributes -> Int
attributeMap :: AttributeMap
attributesCount :: Int
attributesDropped :: Int
..} = Int
attributesCount
getDropped :: Attributes -> Int
getDropped :: Attributes -> Int
getDropped Attributes {Int
AttributeMap
attributeMap :: Attributes -> AttributeMap
attributesCount :: Attributes -> Int
attributesDropped :: Attributes -> Int
attributeMap :: AttributeMap
attributesCount :: Int
attributesDropped :: Int
..} = Int
attributesDropped
lookupAttribute :: Attributes -> Text -> Maybe Attribute
lookupAttribute :: Attributes -> Text -> Maybe Attribute
lookupAttribute Attributes {Int
AttributeMap
attributeMap :: Attributes -> AttributeMap
attributesCount :: Attributes -> Int
attributesDropped :: Attributes -> Int
attributeMap :: AttributeMap
attributesCount :: Int
attributesDropped :: Int
..} Text
k = Text -> AttributeMap -> Maybe Attribute
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
H.lookup Text
k AttributeMap
attributeMap
lookupAttributeByKey :: FromAttribute a => Attributes -> AttributeKey a -> Maybe a
lookupAttributeByKey :: forall a.
FromAttribute a =>
Attributes -> AttributeKey a -> Maybe a
lookupAttributeByKey Attributes {Int
AttributeMap
attributeMap :: Attributes -> AttributeMap
attributesCount :: Attributes -> Int
attributesDropped :: Attributes -> Int
attributeMap :: AttributeMap
attributesCount :: Int
attributesDropped :: Int
..} AttributeKey a
k = AttributeKey a -> AttributeMap -> Maybe a
forall a.
FromAttribute a =>
AttributeKey a -> AttributeMap -> Maybe a
Map.lookupByKey AttributeKey a
k AttributeMap
attributeMap
data AttributeLimits = AttributeLimits
{ AttributeLimits -> Maybe Int
attributeCountLimit :: Maybe Int
, AttributeLimits -> Maybe Int
attributeLengthLimit :: Maybe Int
}
deriving stock (ReadPrec [AttributeLimits]
ReadPrec AttributeLimits
Int -> ReadS AttributeLimits
ReadS [AttributeLimits]
(Int -> ReadS AttributeLimits)
-> ReadS [AttributeLimits]
-> ReadPrec AttributeLimits
-> ReadPrec [AttributeLimits]
-> Read AttributeLimits
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS AttributeLimits
readsPrec :: Int -> ReadS AttributeLimits
$creadList :: ReadS [AttributeLimits]
readList :: ReadS [AttributeLimits]
$creadPrec :: ReadPrec AttributeLimits
readPrec :: ReadPrec AttributeLimits
$creadListPrec :: ReadPrec [AttributeLimits]
readListPrec :: ReadPrec [AttributeLimits]
Read, Int -> AttributeLimits -> ShowS
[AttributeLimits] -> ShowS
AttributeLimits -> String
(Int -> AttributeLimits -> ShowS)
-> (AttributeLimits -> String)
-> ([AttributeLimits] -> ShowS)
-> Show AttributeLimits
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AttributeLimits -> ShowS
showsPrec :: Int -> AttributeLimits -> ShowS
$cshow :: AttributeLimits -> String
show :: AttributeLimits -> String
$cshowList :: [AttributeLimits] -> ShowS
showList :: [AttributeLimits] -> ShowS
Show, AttributeLimits -> AttributeLimits -> Bool
(AttributeLimits -> AttributeLimits -> Bool)
-> (AttributeLimits -> AttributeLimits -> Bool)
-> Eq AttributeLimits
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AttributeLimits -> AttributeLimits -> Bool
== :: AttributeLimits -> AttributeLimits -> Bool
$c/= :: AttributeLimits -> AttributeLimits -> Bool
/= :: AttributeLimits -> AttributeLimits -> Bool
Eq, Eq AttributeLimits
Eq AttributeLimits =>
(AttributeLimits -> AttributeLimits -> Ordering)
-> (AttributeLimits -> AttributeLimits -> Bool)
-> (AttributeLimits -> AttributeLimits -> Bool)
-> (AttributeLimits -> AttributeLimits -> Bool)
-> (AttributeLimits -> AttributeLimits -> Bool)
-> (AttributeLimits -> AttributeLimits -> AttributeLimits)
-> (AttributeLimits -> AttributeLimits -> AttributeLimits)
-> Ord AttributeLimits
AttributeLimits -> AttributeLimits -> Bool
AttributeLimits -> AttributeLimits -> Ordering
AttributeLimits -> AttributeLimits -> AttributeLimits
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
$ccompare :: AttributeLimits -> AttributeLimits -> Ordering
compare :: AttributeLimits -> AttributeLimits -> Ordering
$c< :: AttributeLimits -> AttributeLimits -> Bool
< :: AttributeLimits -> AttributeLimits -> Bool
$c<= :: AttributeLimits -> AttributeLimits -> Bool
<= :: AttributeLimits -> AttributeLimits -> Bool
$c> :: AttributeLimits -> AttributeLimits -> Bool
> :: AttributeLimits -> AttributeLimits -> Bool
$c>= :: AttributeLimits -> AttributeLimits -> Bool
>= :: AttributeLimits -> AttributeLimits -> Bool
$cmax :: AttributeLimits -> AttributeLimits -> AttributeLimits
max :: AttributeLimits -> AttributeLimits -> AttributeLimits
$cmin :: AttributeLimits -> AttributeLimits -> AttributeLimits
min :: AttributeLimits -> AttributeLimits -> AttributeLimits
Ord, Typeable AttributeLimits
Typeable AttributeLimits =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AttributeLimits -> c AttributeLimits)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AttributeLimits)
-> (AttributeLimits -> Constr)
-> (AttributeLimits -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AttributeLimits))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AttributeLimits))
-> ((forall b. Data b => b -> b)
-> AttributeLimits -> AttributeLimits)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AttributeLimits -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AttributeLimits -> r)
-> (forall u.
(forall d. Data d => d -> u) -> AttributeLimits -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> AttributeLimits -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AttributeLimits -> m AttributeLimits)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AttributeLimits -> m AttributeLimits)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AttributeLimits -> m AttributeLimits)
-> Data AttributeLimits
AttributeLimits -> Constr
AttributeLimits -> DataType
(forall b. Data b => b -> b) -> AttributeLimits -> AttributeLimits
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) -> AttributeLimits -> u
forall u. (forall d. Data d => d -> u) -> AttributeLimits -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AttributeLimits -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AttributeLimits -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AttributeLimits -> m AttributeLimits
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AttributeLimits -> m AttributeLimits
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AttributeLimits
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AttributeLimits -> c AttributeLimits
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AttributeLimits)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AttributeLimits)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AttributeLimits -> c AttributeLimits
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AttributeLimits -> c AttributeLimits
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AttributeLimits
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AttributeLimits
$ctoConstr :: AttributeLimits -> Constr
toConstr :: AttributeLimits -> Constr
$cdataTypeOf :: AttributeLimits -> DataType
dataTypeOf :: AttributeLimits -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AttributeLimits)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AttributeLimits)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AttributeLimits)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AttributeLimits)
$cgmapT :: (forall b. Data b => b -> b) -> AttributeLimits -> AttributeLimits
gmapT :: (forall b. Data b => b -> b) -> AttributeLimits -> AttributeLimits
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AttributeLimits -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AttributeLimits -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AttributeLimits -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AttributeLimits -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AttributeLimits -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> AttributeLimits -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> AttributeLimits -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> AttributeLimits -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AttributeLimits -> m AttributeLimits
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> AttributeLimits -> m AttributeLimits
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AttributeLimits -> m AttributeLimits
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AttributeLimits -> m AttributeLimits
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AttributeLimits -> m AttributeLimits
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> AttributeLimits -> m AttributeLimits
Data, (forall x. AttributeLimits -> Rep AttributeLimits x)
-> (forall x. Rep AttributeLimits x -> AttributeLimits)
-> Generic AttributeLimits
forall x. Rep AttributeLimits x -> AttributeLimits
forall x. AttributeLimits -> Rep AttributeLimits x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AttributeLimits -> Rep AttributeLimits x
from :: forall x. AttributeLimits -> Rep AttributeLimits x
$cto :: forall x. Rep AttributeLimits x -> AttributeLimits
to :: forall x. Rep AttributeLimits x -> AttributeLimits
Generic)
deriving anyclass (Eq AttributeLimits
Eq AttributeLimits =>
(Int -> AttributeLimits -> Int)
-> (AttributeLimits -> Int) -> Hashable AttributeLimits
Int -> AttributeLimits -> Int
AttributeLimits -> Int
forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> AttributeLimits -> Int
hashWithSalt :: Int -> AttributeLimits -> Int
$chash :: AttributeLimits -> Int
hash :: AttributeLimits -> Int
Hashable)
unsafeMergeAttributesIgnoringLimits :: Attributes -> Attributes -> Attributes
unsafeMergeAttributesIgnoringLimits :: Attributes -> Attributes -> Attributes
unsafeMergeAttributesIgnoringLimits Attributes
left Attributes
right = AttributeMap -> Int -> Int -> Attributes
Attributes AttributeMap
hm Int
c Int
d
where
hm :: AttributeMap
hm = Attributes -> AttributeMap
attributeMap Attributes
left AttributeMap -> AttributeMap -> AttributeMap
forall a. Semigroup a => a -> a -> a
<> Attributes -> AttributeMap
attributeMap Attributes
right
c :: Int
c = AttributeMap -> Int
forall k v. HashMap k v -> Int
H.size AttributeMap
hm
d :: Int
d = Attributes -> Int
attributesDropped Attributes
left Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Attributes -> Int
attributesDropped Attributes
right
unsafeAttributesFromListIgnoringLimits :: [(Text, Attribute)] -> Attributes
unsafeAttributesFromListIgnoringLimits :: [(Text, Attribute)] -> Attributes
unsafeAttributesFromListIgnoringLimits [(Text, Attribute)]
l = AttributeMap -> Int -> Int -> Attributes
Attributes AttributeMap
hm Int
c Int
0
where
hm :: AttributeMap
hm = [(Text, Attribute)] -> AttributeMap
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
H.fromList [(Text, Attribute)]
l
c :: Int
c = AttributeMap -> Int
forall k v. HashMap k v -> Int
H.size AttributeMap
hm