reflex-0.8.1.0: Higher-order Functional Reactive Programming

Safe Haskell Safe Haskell2010

Data.FastWeakBag

Contents

Description

This module defines the FastWeakBag type, which represents a mutable collection of items that does not cause the items to be retained in memory. This is useful for situations where a value needs to be inspected or modified if it is still alive, but can be ignored if it is dead.

Synopsis

# Documentation

data FastWeakBag a Source #

A FastWeakBag holds a set of values of type a, but does not retain them - that is, they can still be garbage-collected. As long as the a values remain alive, the FastWeakBag will continue to refer to them.

When inserting an item into a FastWeakBag, a FastWeakBagTicket is returned. If the caller retains the ticket, the item is guranteed to stay in memory (and thus in the FastWeakBag). The ticket can also be used to remove the item from the FastWeakBag prematurely (i.e. while it is still alive), using remove.

Create an empty FastWeakBag.

Check whether a FastWeakBag is empty.

Arguments

 :: a The item -> FastWeakBag a The FastWeakBag to insert into -> IO (FastWeakBagTicket a) Returns a FastWeakBagTicket that ensures the item is retained and allows the item to be removed.

Insert an item into a FastWeakBag.

traverse :: forall a m. MonadIO m => FastWeakBag a -> (a -> m ()) -> m () Source #

Deprecated: Use traverse_ instead

traverse_ :: forall a m. MonadIO m => FastWeakBag a -> (a -> m ()) -> m () Source #

Visit every node in the given list. If new nodes are appended during the traversal, they will not be visited. Every live node that was in the list when the traversal began will be visited exactly once; however, no guarantee is made about the order of the traversal.

remove :: FastWeakBagTicket a -> IO () Source #

Remove an item from the FastWeakBag; does nothing if invoked multiple times on the same FastWeakBagTicket.

# Internal functions

Map of items contained by the FastWeakBag