@@ -217,9 +217,13 @@ delete m
217 -- We know we have the element, If the map has exactly one element, we can return the empty map
217 -- We know we have the element, If the map has exactly one element, we can return the empty map
218 | size m == 1 = empty
218 | size m == 1 = empty
219 -- Otherwise, filter out the element in linear time.
219 -- Otherwise, filter out the element in linear time.
220− | otherwise = fromSortedTriples . filter ((/= typeFp @a) . fst3) . toSortedTriples $ m
220+ | otherwise = fromSortedTriples . deleteFirst ((== typeFp @a) . fst3) . toSortedTriples $ m
221{-# INLINE delete #-}
221{-# INLINE delete #-}
223+deleteFirst :: (a -> Bool) -> [a] -> [a]
224+deleteFirst _ [] = []
225+deleteFirst p (x : xs) = if p x then xs else x : deleteFirst p xs
224Update a value at a specific key with the result of the provided function. When
228Update a value at a specific key with the result of the provided function. When
225the key is not a member of the map, the original map is returned.
229the key is not a member of the map, the original map is returned.