reflex-0.5: Higher-order Functional Reactive Programming

Safe HaskellNone



FastWeak is a weak pointer to some value, and FastWeakTicket ensures the value referred to by a FastWeak stays live while the ticket is held (live).

On GHC or GHCJS when not built with the fast-weak cabal flag, FastWeak is a wrapper around the simple version of Weak where the key and value are the same.

On GHCJS when built with the fast-weak cabal flag, FastWeak is implemented directly in JS using h$FastWeak and h$FastWeakTicket which are a nonstandard part of the GHCJS RTS.



data FastWeakTicket a Source #

A FastWeak which has been promoted to a strong reference. getFastWeakTicketValue can be used to get the referred to value without fear of Nothing, and getFastWeakTicketWeak can be used to get the weak version.

type FastWeak a = Weak a Source #

A reference to some value which can be garbage collected if there are only weak references to the value left.

getFastWeakValue can be used to try and obtain a strong reference to the value.

The value in a FastWeak can also be kept alive by obtaining a FastWeakTicket using getFastWeakTicket if the value hasn't been collected yet.

Synonymous with Weak.

mkFastWeakTicket :: a -> IO (FastWeakTicket a) Source #

Create a FastWeakTicket directly from a value, creating a FastWeak in the process which can be obtained with getFastWeakTicketValue.

getFastWeakTicketValue :: FastWeakTicket a -> IO a Source #

Return the a kept alive by the given FastWeakTicket.

This needs to be in IO so we know that we've relinquished the ticket.

getFastWeakTicketWeak :: FastWeakTicket a -> IO (FastWeak a) Source #

Demote a FastWeakTicket; which ensures the value is alive, to a FastWeak which doesn't. Note that unless the ticket for the same FastWeak is held in some other way the value might be collected immediately.

getFastWeakValue :: FastWeak a -> IO (Maybe a) Source #

Get the value referred to by a FastWeak if it hasn't yet been collected, or Nothing if it has been collected.

getFastWeakTicket :: forall a. FastWeak a -> IO (Maybe (FastWeakTicket a)) Source #

Try to create a FastWeakTicket for the given FastWeak which will ensure the value referred remains alive. Returns Just if the value hasn't been collected and a ticket can therefore be obtained, Nothing if it's been collected.

emptyFastWeak :: FastWeak a Source #

A weak reference that is always empty