@@ -217,9 +217,13 @@ delete m
217217 -- We know we have the element, If the map has exactly one element, we can return the empty map
218218 | size m == 1 = empty
219219 -- 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
221221{-# INLINE delete #-}
222222
223+deleteFirst :: (a -> Bool) -> [a] -> [a]
224+deleteFirst _ [] = []
225+deleteFirst p (x : xs) = if p x then xs else x : deleteFirst p xs
226+
223227{- |
224228Update a value at a specific key with the result of the provided function. When
225229the key is not a member of the map, the original map is returned.