reactive-banana-1.3.2.0: Library for functional reactive programming (FRP).

Safe Haskell | None
Language | Haskell98

Reactive.Banana.Prim.Low.Ref

Contents

- Mutable references with `Unique`
- Garbage collection and weak pointers to `Ref`

Synopsis

- data Ref a
- getUnique :: Ref a -> Unique
- new :: MonadIO m => a -> m (Ref a)
- equal :: Ref a -> Ref b -> Bool
- read :: MonadIO m => Ref a -> m a
- put :: MonadIO m => Ref a -> a -> m ()
- modify' :: MonadIO m => Ref a -> (a -> a) -> m ()
- addFinalizer :: Ref v -> IO () -> IO ()
- getWeakRef :: Ref a -> WeakRef a
- type WeakRef v = Weak (Ref v)
- mkWeak :: Ref k -> v -> Maybe (IO ()) -> IO (Weak v)
- deRefWeak :: Weak v -> IO (Maybe v)
- deRefWeaks :: [Weak v] -> IO [v]
- finalize :: WeakRef v -> IO ()

# Mutable references with `Unique`

data Ref a Source #

A mutable reference which has a `Unique` associated with it.

#### Instances

Instances details

NFData (Ref a) Source # |
Instance details Defined in Reactive.Banana.Prim.Low.Ref Methods rnf :: Ref a -> () Source #
Eq (Ref a) Source # |
Instance details Defined in Reactive.Banana.Prim.Low.Ref Methods (==) :: Ref a -> Ref a -> Bool Source # (/=) :: Ref a -> Ref a -> Bool Source #
Hashable (Ref a) Source # |
Instance details Defined in Reactive.Banana.Prim.Low.Ref Methods hashWithSalt :: Int -> Ref a -> Int Source # hash :: Ref a -> Int Source #

getUnique :: Ref a -> Unique Source #

new :: MonadIO m => a -> m (Ref a) Source #

equal :: Ref a -> Ref b -> Bool Source #

read :: MonadIO m => Ref a -> m a Source #

put :: MonadIO m => Ref a -> a -> m () Source #

modify' :: MonadIO m => Ref a -> (a -> a) -> m () Source #

Strictly modify a `Ref`.

# Garbage collection and weak pointers to `Ref`

addFinalizer :: Ref v -> IO () -> IO () Source #

Add a finalizer to a `Ref`.

See `addFinalizer`.

getWeakRef :: Ref a -> WeakRef a Source #

type WeakRef v = Weak (Ref v) Source #

Weak pointer to a `Ref`.

mkWeak Source #

Arguments

:: Ref k | key
-> v | value
-> Maybe (IO ()) | finalizer
-> IO (Weak v) |

Create a weak pointer that associates a key with a value.

See `mkWeak`.

deRefWeak :: Weak v -> IO (Maybe v) Source #

Dereference a `WeakRef`.

See `deRefWeak`.

deRefWeaks :: [Weak v] -> IO [v] Source #

Dereference a list of weak pointers while discarding dead ones.

finalize :: WeakRef v -> IO () Source #

Finalize a `WeakRef`.

See `finalize`.