Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- data Queue d :: Effect where
- Read :: Queue d m (QueueResult d)
- TryRead :: Queue d m (QueueResult d)
- ReadTimeout :: TimeUnit t => t -> Queue d m (QueueResult d)
- Peek :: Queue d m (QueueResult d)
- TryPeek :: Queue d m (QueueResult d)
- Write :: d -> Queue d m ()
- TryWrite :: d -> Queue d m (QueueResult ())
- WriteTimeout :: TimeUnit t => t -> d -> Queue d m (QueueResult ())
- Closed :: Queue d m Bool
- Close :: Queue d m ()
- close :: forall d r. Member (Queue d) r => Sem r ()
- closed :: forall d r. Member (Queue d) r => Sem r Bool
- writeTimeout :: forall d r t. (Member (Queue d) r, TimeUnit t) => t -> d -> Sem r (QueueResult ())
- tryWrite :: forall d r. Member (Queue d) r => d -> Sem r (QueueResult ())
- write :: forall d r. Member (Queue d) r => d -> Sem r ()
- tryPeek :: forall d r. Member (Queue d) r => Sem r (QueueResult d)
- peek :: forall d r. Member (Queue d) r => Sem r (QueueResult d)
- readTimeout :: forall d r t. (Member (Queue d) r, TimeUnit t) => t -> Sem r (QueueResult d)
- tryRead :: forall d r. Member (Queue d) r => Sem r (QueueResult d)
- read :: forall d r. Member (Queue d) r => Sem r (QueueResult d)
Documentation
data Queue d :: Effect where Source #
Abstracts queues like TBQueue
.
For documentation on the constructors, see the module Polysemy.Conc.Data.Queue.
import Polysemy.Conc (Queue, QueueResult) import Polysemy.Conc.Effect.Queue as Queue prog :: Member (Queue Int) r => Sem r (QueueResult Int) prog = do Queue.write 5 Queue.write 10 Queue.read >>= \case QueueResult.Success i -> fmap (i +) <$> Queue.read r -> pure r
Read :: Queue d m (QueueResult d) | Read an element from the queue, blocking until one is available. |
TryRead :: Queue d m (QueueResult d) | Read an element from the queue, immediately returning if none is available. |
ReadTimeout :: TimeUnit t => t -> Queue d m (QueueResult d) | Read an element from the queue, blocking until one is available or the timeout expires. |
Peek :: Queue d m (QueueResult d) | Read an element, leaving it in the queue, blocking until one is available. |
TryPeek :: Queue d m (QueueResult d) | Read an element, leaving it in the queue, immediately returning if none is available. |
Write :: d -> Queue d m () | Write an element to the queue, blocking until a slot is available. |
TryWrite :: d -> Queue d m (QueueResult ()) | Write an element to the queue, immediately returning if no slot is available. |
WriteTimeout :: TimeUnit t => t -> d -> Queue d m (QueueResult ()) | Write an element to the queue, blocking until a slot is available or the timeout expires. |
Closed :: Queue d m Bool | Indicate whether the queue is closed. |
Close :: Queue d m () | Close the queue. |
closed :: forall d r. Member (Queue d) r => Sem r Bool Source #
Indicate whether the queue is closed.
writeTimeout :: forall d r t. (Member (Queue d) r, TimeUnit t) => t -> d -> Sem r (QueueResult ()) Source #
Write an element to the queue, blocking until a slot is available or the timeout expires.
tryWrite :: forall d r. Member (Queue d) r => d -> Sem r (QueueResult ()) Source #
Write an element to the queue, immediately returning if no slot is available.
write :: forall d r. Member (Queue d) r => d -> Sem r () Source #
Write an element to the queue, blocking until a slot is available.
tryPeek :: forall d r. Member (Queue d) r => Sem r (QueueResult d) Source #
Read an element, leaving it in the queue, immediately returning if none is available.
peek :: forall d r. Member (Queue d) r => Sem r (QueueResult d) Source #
Read an element, leaving it in the queue, blocking until one is available.
readTimeout :: forall d r t. (Member (Queue d) r, TimeUnit t) => t -> Sem r (QueueResult d) Source #
Read an element from the queue, blocking until one is available or the timeout expires.