Skip to content

Commit 1930a62

Browse files
author
Benjamin
committed
inline new functions for nonnull
1 parent 130e338 commit 1930a62

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

mono-traversable/src/Data/NonNull.hs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,41 +94,63 @@ instance SemiSetContainer set => SemiSetContainer (NonNull set) where
9494
type ContainerKey (NonNull set) = ContainerKey set
9595

9696
member k = member k . toNullable
97+
{-# INLINE member #-}
9798
notMember k = notMember k . toNullable
99+
{-# INLINE notMember #-}
98100
union = unsafeMap2 union
101+
{-# INLINE union #-}
99102
keys = keys . toNullable
103+
{-# INLINE keys #-}
100104

101105
instance SemiIsMap map => SemiIsMap (NonNull map) where
102106
type MapValue (NonNull map) = MapValue map
103107

104108
lookup k = Data.Containers.lookup k . toNullable
109+
{-# INLINE lookup #-}
105110
insertMap k v = unsafeMap $ insertMap k v
111+
{-# INLINE insertMap #-}
106112
singletonMap k v = NonNull $ singletonMap k v
113+
{-# INLINE singletonMap #-}
107114
mapToList = mapToList . toNullable
115+
{-# INLINE mapToList #-}
108116
findWithDefault def k = findWithDefault def k . toNullable
117+
{-# INLINE findWithDefault #-}
109118

110119
insertWith f k v = unsafeMap $ insertWith f k v
120+
{-# INLINE insertWith #-}
111121
insertWithKey f k v = unsafeMap $ insertWithKey f k v
122+
{-# INLINE insertWithKey #-}
112123
insertLookupWithKey f k v (NonNull mp) = NonNull <$> insertLookupWithKey f k v mp
124+
{-# INLINE insertLookupWithKey #-}
113125

114126
adjustMap f k = unsafeMap $ adjustMap f k
127+
{-# INLINE adjustMap #-}
115128
adjustWithKey f k = unsafeMap $ adjustWithKey f k
129+
{-# INLINE adjustWithKey #-}
116130

117131
unionWith f = unsafeMap2 (unionWith f)
132+
{-# INLINE unionWith #-}
118133
unionWithKey f = unsafeMap2 (unionWithKey f)
134+
{-# INLINE unionWithKey #-}
119135

120136
mapWithKey f = unsafeMap (mapWithKey f)
137+
{-# INLINE mapWithKey #-}
121138
omapKeysWith g f = unsafeMap (omapKeysWith g f)
139+
{-# INLINE omapKeysWith #-}
122140

123141
instance SemiIsSet set => SemiIsSet (NonNull set) where
124142
insertSet e = unsafeMap (insertSet e)
143+
{-# INLINE insertSet #-}
125144
singletonSet = NonNull . singletonSet
145+
{-# INLINE singletonSet #-}
126146
setToList = setToList . toNullable
147+
{-# INLINE setToList #-}
127148

128149
instance HasKeysSet set => HasKeysSet (NonNull set) where
129150
type KeySet (NonNull set) = NonNull (KeySet set)
130151

131152
keysSet = NonNull . keysSet . toNullable
153+
{-# INLINE keysSet #-}
132154

133155
-- | This function is unsafe, and must not be exposed from this module.
134156
unsafeMap :: (mono -> mono) -> NonNull mono -> NonNull mono

0 commit comments

Comments
 (0)