nikita-volkov / stm-containers

Containers for STM
http://hackage.haskell.org/package/stm-containers
MIT License
66 stars 13 forks source link

Add function to delete all elements #6

Closed agentm closed 8 years ago

agentm commented 8 years ago

I am using an STMMap to store some session information. Once a session is done, however, it would be handy to be able to delete the elements from the STMMap. Is there a better way to do this than stream + traverse_ + delete?

nikita-volkov commented 8 years ago

Why not just create a new empty map?

neongreen commented 8 years ago

Here's what I have:

type Cache = STMMap.Map CacheKey BSL.ByteString

cache :: Cache
{-# NOINLINE cache #-}
cache = unsafePerformIO STMMap.newIO

How can I use new or newIO to replace cache with an empty map? There might be a way but currently I don't see it.

nikita-volkov commented 8 years ago

Okay. For such an edge case it makes sense. It's released now.

neongreen commented 8 years ago

Whoa, that was fast. Thanks!